I'm working on an embedded system with very few resources available, I seem to be able to launch individual threads without too much delay elsewhere, but when I queue a task in the ThreadPool as mentioned in the title, there is a very noticeable graphical delay while it is queuing or performing the task.
The call looks like:
NetManager nPart = new NetManager();
ThreadPool.QueueUserWorkItem(nPart.DoPartCountUpdate, _partManager.PartProduced);
The lag is most noticeable on the fist call, subsequent calls appear to cause less issues (most of the time).
I wanted to use this to avoid creating too many threads.
Edit:
To be honest, this is probably a case where the embedded device should just have more than 1 gig of RAM while running Win 7 embedded... nonetheless, maybe a better way to queue the task.
Edit 2:
I've tried doing things like
int min, max;
ThreadPool.GetAvailableThreads(out min, out max);
ThreadPool.SetMinThreads((min + 5), (max + 5));
But the lag does not change noticably in any way. At this point I'd rather use something else as I can't seem to get the thread pool to react quickly enough.
Simply launching my own thread seems like a better option at this point, unless there is a better alternative?
I should also note that it is definitely the CPU that is the bottleneck. I can see it maxing out at 100% usage when the lag happens.