By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,402 Members | 1,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,402 IT Pros & Developers. It's quick & easy.

Rapid creation and Abortion of threads

P: n/a
Hi,
My application requires to create a few threads on the
occurance of an event E1 and the same threads need to be
aborted on the occurance of another event E2. Iam not
using .Net thread pool threads. Iam using system threads
by using Thread objects and delegates. Threads are aborted
by making an explicit call to Thread.Abort().

Occurance of events E1 and E2 are not under the control of
my application. My application runs stable for a few hours
but once E1 and E2 start repeatedly occuring at a very
fast rate, new threads are also started and aborted at a
very fast rate. As a result, some threads are not aborted.
Apparently, there is a thread leak, memory leak in my
application.

So, how do i ensure that the threads are aborted and are
removed from memory?

Thanks in advance.
Jagadish

Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jagadish, are you sure that threads aren't being aborted? Have you tried
putting some logging in to ensure that that is in fact what is going on?
You can also watch the thread count for your app using Task Manager.

My guess is that your threads are being aborted and cleaned up but that it
isn't happening when you would expect when E1 and E2 happen quickly. If
that's not the case could you include some code demonstrating what you are
seeing?

--
Greg Ewing [MVP]
http://www.claritycon.com/

"Jagadish" <ja****@hotmail.com> wrote in message
news:1b****************************@phx.gbl...
Hi,
My application requires to create a few threads on the
occurance of an event E1 and the same threads need to be
aborted on the occurance of another event E2. Iam not
using .Net thread pool threads. Iam using system threads
by using Thread objects and delegates. Threads are aborted
by making an explicit call to Thread.Abort().

Occurance of events E1 and E2 are not under the control of
my application. My application runs stable for a few hours
but once E1 and E2 start repeatedly occuring at a very
fast rate, new threads are also started and aborted at a
very fast rate. As a result, some threads are not aborted.
Apparently, there is a thread leak, memory leak in my
application.

So, how do i ensure that the threads are aborted and are
removed from memory?

Thanks in advance.
Jagadish

Nov 15 '05 #2

P: n/a
Abort does not guarantee a thread to abort. Look into the Win32 API
TerminateThread. (along with a number of others that you need to use to get
a real HANDLE, duplicate it, and then finally close it out.)
--
Justin Rogers
DigiTec Web Consultants, LLC.

"Jagadish" <ja****@hotmail.com> wrote in message
news:1b****************************@phx.gbl...
Hi,
My application requires to create a few threads on the
occurance of an event E1 and the same threads need to be
aborted on the occurance of another event E2. Iam not
using .Net thread pool threads. Iam using system threads
by using Thread objects and delegates. Threads are aborted
by making an explicit call to Thread.Abort().

Occurance of events E1 and E2 are not under the control of
my application. My application runs stable for a few hours
but once E1 and E2 start repeatedly occuring at a very
fast rate, new threads are also started and aborted at a
very fast rate. As a result, some threads are not aborted.
Apparently, there is a thread leak, memory leak in my
application.

So, how do i ensure that the threads are aborted and are
removed from memory?

Thanks in advance.
Jagadish

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.