In the mainPage.Load (mainPage is the page loaded by Main()) I have this code (stripped to reflect the problem):
step = “11”;
var f = new frmLogin();
step = “12”;
if (f.ShowDialog() == DialogResult.Cancel)
step = “12.1”;
step = “13”;
catch (Exception ex)
utils.Log(“mainPage_Load error:” + ex.Message + ” (” + step+ “)”);
And in log I have: mainPage_Load error:Thread was being aborted. (12)
There are several logs like that, but it doesn’t seems to affect the program. Or at least I didn’t had problems when testing. The program is in production environment.
What does this error means? Any way to avoid it?
Does it happen when the session is abandoned? If that’s the case then it’s normal. The thread is aborted or you end up executing the code after the dialog. You have to be careful when catching the exception and check for ThreadAbortException in case you are executing code.
In .NET there is a special exception called ThreadAbortException that can be caught but cannot escape the try/catch block (the code outside will never be executed even if you catch the exception). And it cannot be thrown, it’s raised by Thread.Abort(). It is designed to more or less gracefully abort a thread.
In ASP.NET it’s fired hundreds of times when using Transfer or response.End(). You may read some blogs telling you that it shouldn’t be used. They just don’t know how threading works.
Please login first to submit.