I want to limit the number of threads in my multi-threaded WCF service. So, I am using the ThreadPool.SetMaxThread function. Now I want to use System.Timers to generate events at given intervals.
But my service at the same time gets a lot of actions to perform in the thread pool. When my timer has expired, the action is queued in ThreadPool (I sometimes have 100,000 tasks waiting) and therefore slower to complete.
Is there a way to execute my past event earlier? For example, setting a priority job in a queue on threadpool? Or an expired event outside the stream?
I want to keep my global thread limit in my service.
source share