Thread.Abort Question?

S

Steve

Hello,

I have a subroutine, sub1 that creates 2 new Threads.
Each Thread then runs a subroutine of their own. Sub1 is
on a timer and when called will create 2 new threads each
time. I observed the Windows Task Manager Performance Tab
for the count of threads, handles, processes. I let Sub1
run several times and create several threads. I thought
of terminating each thread with Thread.Abort. Task
Manager does show an increase in threads when Sub1 creates
the new threads. But when the subroutines in the new
threads have completed, the thread count goes down in Task
Manager whether I use Thread.Abort or not. I have not yet
tested sub1 for a several day interval.

Could someone advise me if I need to terminate these
threads if I will be creating new ones on a timed
schedule? Is Thread.Abort the correct way to terminate
these threads?

Thanks
 
T

Tom Shelton

Hello,

I have a subroutine, sub1 that creates 2 new Threads.
Each Thread then runs a subroutine of their own. Sub1 is
on a timer and when called will create 2 new threads each
time. I observed the Windows Task Manager Performance Tab
for the count of threads, handles, processes. I let Sub1
run several times and create several threads. I thought
of terminating each thread with Thread.Abort. Task
Manager does show an increase in threads when Sub1 creates
the new threads. But when the subroutines in the new
threads have completed, the thread count goes down in Task
Manager whether I use Thread.Abort or not. I have not yet
tested sub1 for a several day interval.

Could someone advise me if I need to terminate these
threads if I will be creating new ones on a timed
schedule? Is Thread.Abort the correct way to terminate
these threads?

Thanks

A thread ends when it's method exits. So, you don't need to call
Thread.Abort, unless you want to cause an early termination of your
thread.
 

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