user215675
user215675

Reputation: 5181

C# Threads - Interruption

Normally will we interrupt a thread which is in "WaitSleepJoin" state or "Running" state?

Upvotes: 2

Views: 243

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1503419

Normally you don't interrupt a thread at all... but if you try to, it won't actually be interrupted until it next blocks. From MSDN:

If this thread is not currently blocked in a wait, sleep, or join state, it will be interrupted when it next begins to block.

ThreadInterruptedException is thrown in the interrupted thread, but not until the thread blocks. If the thread never blocks, the exception is never thrown, and thus the thread might complete without ever being interrupted.

Upvotes: 5

Related Questions