I am creating a few windows forms with many controls on it asynchronously (each on a thread created with a sole purpose to open that form).
for(var i = 0; i < 10; i++)
{
var thread = new Thread(() =>
{
var form = new FormX();
form.ShowDialog();
});
thread.Start();
}
I always get this error "Error Creating Window Handle". I tried googling that the limit is 10.000 handles. However, I have another thread that checks the amount of handles like this:
var handleThread = new Thread(() =>
{
while(true)
{
System.Diagnostics.Debug.WriteLine(System.Diagnostics.Process.GetCurrentProcess().HandleCount);
}
});
handleThread.Start();
At maximum it prints out like 800, which is nowhere near the limit.
What could be the problem?