Killing off a thread..

  • Thread starter Thread starter Mantorok
  • Start date Start date
M

Mantorok

Hi all

I have an app that runs report classes, each report is run in a new thread,
what I want is the ability to be able to kill of a thread that is running.

How is this best achieved?

Thanks
Kev
 
Mantorok said:
I have an app that runs report classes, each report is run in a new
thread, what I want is the ability to be able to kill of a thread that is
running.

How is this best achieved?

You really can't kill threads - doing will have all sorts of ugly results.

A better approach is to have an event of some sort, usually a
ManualResetEvent, called "_shouldShutdown". Have your worker threads poll
this event periodically, and if the event is set then have the thread exit.
 
Back
Top