I would like to call _myThread.Abort() after my ManualResetEvent blocked a thread. So either I want to check whether the Thread is already blocked, or I want to call a delegate which only calls _myThread.Abort() right after the thread has been paused.
So far i got:
public void MyPause()
{
if (_myManualResetEvent == null)
return;
else
_myManualResetEvent.Reset();
}
public void MyResume()
{
if (_myManualResetEvent == null)
return;
else
_myManualResetEvent.Set();
}
public void MyAbort()
{
if (_myManualResetEvent == null)
return;
else
{
//???
}
}
Something like asking _myManualResetEvent.WaitOne(0) does not work, since it simply returns the state of a ManualResetEvent, which may differ to the actual thread state, but I want to know if the thread is already blocked (which implies it has already called WaitOne()). Checking the thread state does not work, since ManualResetEvent uses System.Threading.ThreadState.WaitSleepJoin, like many other functions do.