> > I'm sorry but that doesn't help. I did this:
> > if (snmpThread.ThreadState == (System.Threading.ThreadState.WaitSleepJoin |
[quoted text clipped - 12 lines]
>
> See http://www.pobox.com/~skeet/csharp/threads/shutdown.shtml
> What do you mean by "don't call sleep or Abort"? My thread work loop is doing
> something like that:
[quoted text clipped - 7 lines]
> and not to raise some "stop" flag and wait for it to stop gracefully (as in
> the article you pointed).
And did you read *why* a graceful stop is preferrable?
> The thing is that the Abort method does not abort the thread while in sleep
> state. I tried the Interrupt method as Kevin suggested and according to the
> MSDN this method should interrupt a sleep state but it doesn't so i don't
> know what else to do.
Well you could try reading the article I linked to before once again...
even if you're still going to call Abort (which I urge you not to do
unless you're taking down the AppDomain) you can still use the rest of
the information in there - use Monitor.Wait or a WaitHandle of some
description instead of Sleep, and then you just need to pulse the
appropriate monitor or set the event after you've called Thread.Abort.
You need to accept, however, that calling Abort is not going to
guarantee an immediate abort. If you're in unmanaged code for whatever
reason, it won't abort the thread until that finishes anyway.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too