Issue with maxWorkerThreads and thread count
- by Kartik M
I have created an ASP.NET application which creates threads in an infinite loop. I set maxWorkerThreads to 20 in processModel in machine.config.
When I checked the Thread count in perfmon there was around 7000 threads created in worker process.
In PageLoad() I have:
using System.Threading;
...
int count = 0;
var threadList = new System.Collections.Generic.List<System.Threading.Thread>();
try
{
while (true)
{
Thread newThread = new Thread(ThreadStart(DummyCall), 1024);
newThread.Start();
threadList.Add(newThread);
count++;
}
}
catch (Exception ex)
{
Response.Write(count + " : " + ex.ToString());
}
Function:
void DummyCall()
{
System.Threading.Thread.Sleep(1000000000);
}
How do I restrict thread creation in ASP.NET with IIS6/7?