Service Question


A

Analizer1

dot.net 2.0 c#

i have 2 Questions....easy one 1st
How to destroy a object within itself without calling dispose
example
namespace mytest
{
class someclass
{
private someobject;
public someclass(){
someobject = new someobject();
}
public void Destroy
{
someobject=null;
//code to set this = null
}
}
}
/// 2nd question
I have a windows service that starts a thread manager
example from onstart
public void OnStart()
//manager is a private field of the service
Manager=new ThreadManager()
//initthreads creates all the worker threads
if (Manager.InitThreads()==false)
{
this.stop() ;
}

//here is my question
should i run the manager on its own Thread or is the above ok...there is
a timer started and maintained when
Manager.InitThread() Runs....and all works just fine...?
 
Ad

Advertisements

I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Analizer1 said:
dot.net 2.0 c#

i have 2 Questions....easy one 1st
How to destroy a object within itself without calling dispose

You cannot destroy an object from itself, an object is marked as collectable
when no references exist to it. Now you are calling Destroy from another
method, that calling method holds a reference to the instance, hence the
instance will not be destroyed. You can release any internal
references/resources you have. but you this probably will make the status of
the instance unknow
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top