J
Jon Slaughter
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
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