I have a C # Windows service that runs various objects (class libraries). Each of these objects has its own "processing" logic, which launches several long-running processing threads using ThreadPool . I have one example, for example:
System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(WorkerThread_Processing));
This works great. My application works without problems, and my threads work well.
Now, to test regression, I run the same objects up, but from a C # Console application, not from a Windows service. It calls the exact same code (because it calls the same objects), however the WorkerThread_Processing method WorkerThread_Processing delayed up to 20 seconds before running.
I went and switched from ThreadPool to Thread , and the problem disappeared. What could be here? I know that I am not older than MaxThreads count (I start 20 max threads).
Mattw source share