Possible duplicate question: http://stackoverflow.com/questions/142826/is-there-a-way-to-indefinitely-pause-a-thread
In my code i do the below
Thread mainThread
//...
mainThread.Resume();
void StartThread()
{
while (!wantQuit)
{
db.runEmail();
mainThread.Suspend();
}
}
Then i get the exception below because i call resume when it hasnt been suspended.
System.Threading.ThreadStateException
I notice 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 i wonder is there a way to resume and ignore the exception/case that it is not suspended? I hate writing the below instead of just one line
try
{
mainThread.Resume();
}
catch (System.Threading.ThreadStateException e)
{
}