Handle leaks with .NET System.Threading.Thread class
Posted
by Mahno
on Stack Overflow
See other posts from Stack Overflow
or by Mahno
Published on 2010-05-24T08:58:59Z
Indexed on
2010/05/24
9:01 UTC
Read the original article
Hit count: 281
I've a problem that number of Handles in my app is continuously growing. I did the debugging and recognize that this is caused by System.Threading.Thread class which is used for some routine. To simplify the debugging I’ve created a sample .NET application:
...
private void button1_Click(object sender, EventArgs e)
{
Thread t = new Thread(DoWork);
t.Start();
}
public void DoWork(object parameter)
{
// Do something...
}
...
Each time I’m clicking the button, a thread is created using System.Threading.Thread class. The problem is that looks like the thread do not frees Handles because each click cause number of Handles growing by ~5.
The question is: how can I manually free all Handles created by System.Threading.Thread class?
Thanks in advance.
© Stack Overflow or respective owner