重複する可能性のある質問: スレッドを無期限に一時停止する方法はありますか?
私のコードでは、以下を行います
Thread mainThread
//...
mainThread.Resume();
void StartThread()
{
while (!wantQuit)
{
db.runEmail();
mainThread.Suspend();
}
}
次に、中断されていないときに再開を呼び出すため、以下の例外が発生します。
System.Threading.ThreadStateException
この警告に気づきました
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'
だから、中断されていない例外/ケースを再開して無視する方法はあるのだろうか? 1行だけではなく、以下を書くのは嫌いです
try
{
mainThread.Resume();
}
catch (System.Threading.ThreadStateException e)
{
}