Possible duplicate question: Is there a way to suspend the thread endlessly?
In my code I do below
Thread mainThread
mainThread.Resume();
void StartThread()
{
while (!wantQuit)
{
db.runEmail();
mainThread.Suspend();
}
}
Then I get the exception below because I call the resume when it has not been paused.
System.Threading.ThreadStateException
I noticed this warning
warning CS0618: 'System.Threading.Thread.Resume()' is obsolete: 'Thread.Resume has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. http://go.microsoft.com/fwlink/?linkid=14202'
So wondering, is there a way to resume and ignore the exception / case where it is not paused? I hate writing below, not just one line
try
{
mainThread.Resume();
}
catch (System.Threading.ThreadStateException e)
{
}
user34537
source
share