Here is a quick pseudo of my app
ImageDT is a DataTable
Parallel.ForEach(ImageDT.AsEnumerable(), row =>
{
if (a1 != a2)
{
ThreadPool.QueueUserWorkItem(Foo1, row["foo"])
}
else
{
ThreadPool.QueueUserWorkItem(Foo2, row["foo"])
}
}
I need to know how many threads are active and how many are queued for Parallel and the ThreadPool.
Thanks
Keep track of a couple of shared integers, “Queued” and “Active.” Increment Queued when you queue a WorkItem. When your callback method starts, have it decrement Queued and increment Active. When the callback exits, decrement Active.