J
Jayme Pechan
I was wondering if someone could help me understand why it seems that
creating threads using the code below causes handles to seemingly leak.
System.Threading.Thread threadRunAsync = new
System.Threading.Thread(RunFunc);
threadRunAsync.Start(listParams);
I have to use ThreadPools in order to avoid the handle leaks.
System.Threading.ThreadPool.QueueUserWorkItem(new
System.Threading.WaitCallback(RunFunc), listParams);
All I can figure is that it was done to discourage people from spawning
short lived threads and to encourage the use of thread pools. Any thoughts
that might help me understand this would be helpful. Sometimes I have items
that I'd like to run in a thread because they run for a long time and I
don't want the thread pool to be used up but I also don't want to have to
reboot my application every month either just to clear up the handles from
these threads. I thought about reverting to a whole new process for such
things but that's more painful.
Thanks
Jayme
creating threads using the code below causes handles to seemingly leak.
System.Threading.Thread threadRunAsync = new
System.Threading.Thread(RunFunc);
threadRunAsync.Start(listParams);
I have to use ThreadPools in order to avoid the handle leaks.
System.Threading.ThreadPool.QueueUserWorkItem(new
System.Threading.WaitCallback(RunFunc), listParams);
All I can figure is that it was done to discourage people from spawning
short lived threads and to encourage the use of thread pools. Any thoughts
that might help me understand this would be helpful. Sometimes I have items
that I'd like to run in a thread because they run for a long time and I
don't want the thread pool to be used up but I also don't want to have to
reboot my application every month either just to clear up the handles from
these threads. I thought about reverting to a whole new process for such
things but that's more painful.
Thanks
Jayme