How to close a thread and free it's resource in .net compact framework?

  • Thread starter Thread starter John
  • Start date Start date
J

John

I had created a thread and started it (tt.start()) in my application, so
that while i want to exit the program, how to kill the tt thread? in .net
CF, there is no Abort() function!
 
Generally speaking, either a new thread is spawned to perform some task then
it stops, or it is create and started with the intention of looping through
something (saving to disk every minute, polling a data base etc etc).

The first use doesn't require anything to stop it because the action should
take a small preportion of time and resources. For the second point, you
shouldn't need to use Abort at any point. Ideally your application would
have a static "IsRunning" flag which is turned on and off by the main
thread, and which all other threads check after every operation to see if
it's time to stop.

Jon Skeet addresses this in his Multithreading article.
http://www.yoda.arachsys.com/csharp/threads/shutdown.shtml
 
OK, I see, thanks!!!
Dan Bass said:
Generally speaking, either a new thread is spawned to perform some task then
it stops, or it is create and started with the intention of looping through
something (saving to disk every minute, polling a data base etc etc).

The first use doesn't require anything to stop it because the action should
take a small preportion of time and resources. For the second point, you
shouldn't need to use Abort at any point. Ideally your application would
have a static "IsRunning" flag which is turned on and off by the main
thread, and which all other threads check after every operation to see if
it's time to stop.

Jon Skeet addresses this in his Multithreading article.
http://www.yoda.arachsys.com/csharp/threads/shutdown.shtml
 
Back
Top