Home »

How do I stop a thread?

Question ListCategory: ASP.NETHow do I stop a thread?
jeanderson295 author asked 1 year ago
1 Answers
shah_kajal184 author answered 10 months ago

There are several options. First, you can use your own communicationmechanism to tell the ThreadStart method to finish. Alternatively the Thread
class has in-built support for instructing the thread to stop. The two principle
methods are Thread.Interrupt() and Thread.Abort(). The former will cause a
ThreadInterruptedException to be thrown on the thread when it next goes
into a WaitJoinSleep state. In other words, Thread.Interrupt is a polite way of
asking the thread to stop when it is no longer doing any useful work. In
contrast, Thread.Abort() throws a ThreadAbortException regardless of what
the thread is doing. Furthermore, the ThreadAbortException cannot normally
be caught (though the ThreadStart’s finally method will be executed).
Thread.Abort() is a heavy-handed mechanism which should not normally be

Please login or Register to Submit Answer