using System; using System.Threading; public delegate void LoadingProgressCallback(double PercentComplete,string ItemName); public delegate void
One thing that immediately comes to mind looking at the code is lack of use of Interlocked.
Interlocked
You have to use it otherwise you will see strange errors and behaviours.
So instead of
numThreads++;
Use:
Interlocked.Increment(ref numThreads);