The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

haacked (1) [Avatar] Offline
Hello. I enjoyed the book, but have a question about using Thread.Abort(). I get the impression that you recommend using Thread.Abort() when monitoring a thread to stop it over using a status variable and having the thread check the status var.

Is that the case? According to this MSDN article
they recommend against using Thread.Abort() on another thread. Are there cases that you feel are exceptions to this guideline?
DamonCarr (7) [Avatar] Offline
Re: Using Thread.Abort()?
Microsoft is correct (no disrespect Dan - I presented on Multithreading tonight and gave away your book. I will email you my slides). Aborting a thread should be avoided for a number of reasons.

Juval Lowey, one of my favorite authors, See:

Killing a Thread
Do not call Abort()
Thread may need to do clean-up
Abort() does not allow graceful exit
The thread method should check a flag
Protect flag with mutex
Kill() method should set flag and wait for thread to terminate
Abort() has another flaw: Thread can do indefinite processing in catch{} Application

public class WorkerThread : IDisposable
protected Thread m_ThreadObj;
protected bool m_EndLoop;
protected Mutex m_EndLoopMutex;
protected bool EndLoop
m_EndLoop = value;
bool result = false;
result = m_EndLoop;
return result;
public WorkerThread()
m_EndLoop = false;
m_ThreadObj = null;
m_EndLoopMutex = new Mutex();

Kind Regards,
Damon Wilder Carr, Chief Technologist and CEO

.NET SIG Leader - New York Software Industry Association (NYSIA
Founder and President: 'Association for the Advancement of Software Engineering in .NET' (AASET)
Microsoft Certified Partner
Visual Studio Industry Partner Affiliate
Professional Member - Association for Computing Machinery (

80 Broad Street
5th Floor
New York, NY 10004

Voice 212.837.7788
Fax 212.859.7359