Re: Thread ending



Jon,

Why you want to restart it, a thread is removed by the system when it is
ready, just start a new thread is more normally done.

Can you tell us therefore what is the reason for you to restart it.

Cor

"Jon Slaughter" <Jon_Slaughter@xxxxxxxxxxx> schreef in bericht
news:4XO8h.209$wc5.175@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Since a thread doesn't have a Stop feature and I'm not supose to use
abort, I'm wondering how I stop a thread?

My problem is that I simply want to excute a function in the background
and possibly "restart" it.

What've been doing is essentially:

if (SerialRowThread != null)

{

SerialRowThread.Abort();

WaitingThread.Stop();

}



WaitingThread.Start();




SR.Setup(domainUpDown1.SelectedIndex, Intervals, Entries);

SerialRowThread = new Thread(SR.Compute);

SerialRowThread.Start();



----



SR is the class that contains the method compute and SR.Setup sets up the
state.



now this works but I'm wondering if I can just suspend the thread and it
will do the same but not use abort.



i.e., the GC will end up disposing of the thread because I reassign
SerialRowThread. So it will, hopefully, inherently call abort on the
thread or do whatever clean its suppose to do.

Is this method ok(i.e., calling suspend instead of abort in the above
code) or do I need to use some method of pooling threads? I'm still not to
clear on how a thread shuts down because even in pooling it must be done?

Thanks,

Jon




.



Relevant Pages

  • Thread ending
    ... Since a thread doesn't have a Stop feature and I'm not supose to use abort, ... SerialRowThread = new Thread; ... calling suspend instead of abort in the above code) ... or do I need to use some method of pooling threads? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: InvalidComObjectException, threaded db access
    ... COM apartments either. ... > If I wait until the thread has done running and restart the thread again, ... > Currently I 'm stopping the running thread with .Abortand catching the ... > getting as I suspect .Abort() is not the good way to go. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Thread ending
    ... Can you tell us therefore what is the reason for you to restart it. ... So I don't want to start another thread that computes the new primes while ... parameters but everywhere I read says that abort is not the way to go yet ... But the suspend() is depreciated in 2.0;/ Seems the only thing I'm ...
    (microsoft.public.dotnet.languages.csharp)
  • InvalidComObjectException, threaded db access
    ... underlying RCW can not be used. ... If I wait until the thread has done running and restart the thread again, ... Currently I 'm stopping the running thread with .Abort() and catching the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Lsa Shell application error
    ... vulnerability of the LSASS.EXE. ... To abort the shut down, click Start, click Run and type "shutdown -a" ... "Tony Darling" wrote in message ... > and then does an orderly shut down and restart. ...
    (microsoft.public.windowsxp.security_admin)