Thread is not user-suspended; it can not be resumed

A

Amratash

I'm receiving the above mentioned error.The problem is:
"I suspend one thread.Another thread is resuming the first thread.Then I
added following code:Its in simple english
if(first thread is not suspended)
then sleep(100)
else
resume first Thread
After adding this code every thing is fine.
Its in C#.
So my question is When we suspend thread, is it suspended at that time only
or it take some time to suspend?
 
J

Jhon

Amratash said:
I'm receiving the above mentioned error.The problem is:
"I suspend one thread.Another thread is resuming the first thread.Then I
added following code:Its in simple english
if(first thread is not suspended)
then sleep(100)
else
resume first Thread
After adding this code every thing is fine.
Its in C#.
So my question is When we suspend thread, is it suspended at that time only
or it take some time to suspend?

<snip from MSDN .NET >
Unlike Thread.Sleep, Thread.Suspend does not cause a thread to immediately
stop execution. The common language runtime must wait until the thread has
reached a safe point before it can suspend the thread.
....
When one thread calls Thread.Suspend on another thread, the call is a
_nonblocking_ call that causes the other thread to pause.
....
threadstate goes from
SuspendRequested
Suspended

</snip>

HTH

greetz
 

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