Killing off a thread..

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
 
C

Chris Mullins

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top