Aborting thread while suspended problem

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
 
S

Stu Smith

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top