I have a dialog that has to process large quantaties of data (the procedure is quite time consuming – first the ODBC fill takes its time, then the data processing kicks in) and the result is that the Form becomes unresponsive. This is not a problem really, it is enough to just open a ‘loading screen’ in a new thread to notify the user of the process.
Recently I have discovered, that sometimes (it appears to be random) the new thread will throw an unhandled ThreadAbortException causing a crash report dialog box to show up (or JIT).
I do not understand why this exception would be thrown, or why it would be unhandled. Has anyone dealt with this before, or can anyone point me towards the probable cause of this behaviour?
Thank you!
EDIT: In case it matters, I open the loading screen like this:
//start of work load Thread th = new Thread(new ThreadStart(MakeStep)); th.Start(); ... //end of work or error occurance: th.Abort();
//
You’re calling
th.Abort()which injects aThreadAbortExceptionon the threadth. If that thread doesn’t handle the exception it will be reported as an unhandled exception.It is generally not recommended to abort other threads in this way, as you have no idea if the thread will handle an abort gracefully. A better solution is to use signaling between your threads.