Multi thread.NET application throws an application error in KERNEL32.dll running on 64 bit quad core Windows Server

I have a .NET multithreaded application that sometimes ends without any message. When I check the log, the entry "Application error in KERNEL32.dll" appears. What could be causing this? Here's the basic code:

foreach (int id in ids)
{
   ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessData), id);
}

      

The ProcessData method looks like this:

private void ProcessData(object _id)
//Load some data from a database with id = _id
//Process that data and push it to another server using HTTP
//Increment a counter

Interlocked.Increment(ref counter);

//Update progress bar
try
{
  // Invoke the delegate on the form.
  this.Invoke(new BarDelegate(UpdateBar), counter);
}
catch {}
}

      

In some cases, millions of identifiers can be processed. But simply testing with 10,000 IDs usually causes the described application problem. Am I doing it right?

Thanks for the help!

+2


source to share


1 answer


Does it always QueueUserWorkItem

return true?



Also, are there any exceptions in this empty catch?

+1


source







All Articles