Safe Termination of application when using ThreadPool threads in .NETCF2.0.

Hi all,

I'm successfully (I think ;p) making use of the ThreadPool class to launch short running asynchronous worker threads to process SMS messages on a WM5 device. When the worker method completes (even in event of exception) it calls another method that fires an event. This event calls bound methods on the form class. These methods create delegates and make use of the form.BeginInvoke to asynchronously marshall updates to the UI safely using the UI thread itself.

My concern through all of this is application termination. I don't know how or if its possible to check the ThreadPool for running threads. It is very unlikely but I don't want to cause problems. Although I try my best to avoid exceptions from locking up threads I don't know how to ensure this doesn't cause a problem I'm not tracking these threads, although its very unlikely more than one is running at once I'm not preventing this from actually happening. Should I be tracking this thread using a AutoResetEvent()

Am I worrying about nothing or should I be taking precautions here

TIA

NozFx



Answer this question

Safe Termination of application when using ThreadPool threads in .NETCF2.0.

  • Safe Termination of application when using ThreadPool threads in .NETCF2.0.