Main Site Documentation

Thread problem


I have a thread, say myThread

I have a lengthy routine that also activates it: myThread.start(0);

another routine stops it: myThread.Suspend();

but when I rerun the original routine to start the thread (actually restart it), I get an unhandled exception error. Is there a way around this? its just a timer to increment a value.


Sounds like you need to do the following:

Within your thread:
–Check a condition for when the thread should exit (WaitHandle)

Outside of the Thread:
–Set the condition.
–call Join statement on the thread object waiting for it to exit.
–Then restart it.

Hope this helps


If you use Suspend on a Thread, you must use Resume to resume it. You can not restart a Thread. You can only create a new Thread and start that one.


Yes, if you Suspend your thread, you should call Resume your thread before you do anything with that thread, even Abort, Close.