Aborting thread while suspended problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I experience a ThreadStateException while trying to abort a thread that is in a Suspended state. According to the MSDN documentation if Abort() is called on a thread that has been suspended, the thread is resumed and then aborted. But obviously it is not the case. I even made a construct like
if(simulationThread.ThreadState == ThreadState.Suspended
simulationThread.Resume()
simulationThread.Abort()
The strangest thing is that even though the thread is suspended,this check results to false and the Resume method is not called
What could be the problem and possible solutions
Thanks in advance
Svetoslav
 
Just off the top of my head, isn't ThreadState a bit enumeration? So the
test probably ought to be:

if((simulationThread.ThreadState & ThreadState.Suspended) ==
ThreadState.Suspended)

I'm probably way off though.


Svetosalv Vasilev said:
Hi, I experience a ThreadStateException while trying to abort a thread
that is in a Suspended state. According to the MSDN documentation if Abort()
is called on a thread that has been suspended, the thread is resumed and
then aborted. But obviously it is not the case. I even made a construct
like:
if(simulationThread.ThreadState == ThreadState.Suspended)
simulationThread.Resume();
simulationThread.Abort();
The strangest thing is that even though the thread is suspended,this check
results to false and the Resume method is not called.
 
Back
Top