Questions tagged [threadabortexception]

Use this tag for questions related to the ThreadAbort exception.

Quoting the MSDN page:

The exception that is thrown when a call is made to the Abort method. This class cannot be inherited.

is commonly found along with , so you might want to include it in your question.

89 questions
18
votes
2 answers

Thread aborted exceptions in wcf service

I have a WCF service (built in .NET framework 3.5) hosted on IIS 6.0. The flow of the code is as follows Client (which is another web service) calls the WCF service WCF services invokes a thread to do the processing in background and responds to…
shivkumar
  • 219
  • 2
  • 6
12
votes
2 answers

Can I detect when a background Thread is killed by the application when the application closes?

I'm using a thread in C# where I've set the IsBackground property to true. The thread is running some code in a loop until the application closes. When the application is closed the thread also stops executing (because I've set IsBackground =…
Ben Adams
  • 564
  • 1
  • 4
  • 18
10
votes
4 answers

Thread.Abort in ASP.NET app causes w3wp.exe to crash

Please do not set duplicate flag on this qustion - it is not about "why ThreadAbortException occurs", it is about "why w3wp.exe process terminates after ThreadAbortException". Let's say we have simple web application with following code…
user2440074
6
votes
2 answers

Why CLR re-throws ThreadAbortException?

I got the following code from book "Concurrent Programming on Windows" : void Main() { try { try { Console.WriteLine("Inside Main Method"); Thread.CurrentThread.Abort(); } …
Pawan Mishra
  • 7,212
  • 5
  • 29
  • 39
6
votes
5 answers

Does ThreadAbortException still enforce executing the code in finally (try/catch) section?

I have a System.Timers.Timer timer which it's AutoReset is set to false. I use a try/finally to insure I Start the timer at the end of it's callback (I use the timer this way to prevent overlapping of callback execution). Code: // inside timer call…
Xaqron
  • 29,931
  • 42
  • 140
  • 205
6
votes
0 answers

Can WaitHandle.WaitOne throw a ThreadAbortException?

I'm getting the following exception: Exception of type ThreadAbortException occurred: System.Threading.ThreadAbortException: ThreadAbortException at System.Threading.EventWaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext) at…
Daz Eddy
  • 332
  • 2
  • 15
6
votes
1 answer

Try/Catch not catching System.Threading.ThreadAbortException in ReportDocument.ExportToHttpResponse

I am trying to export a Crystal ReportDocument using ExportToHttpResponse like so: report.ExportToHttpResponse(exportOptions, HttpContext.Current.Response, true, "test"); When I first tried to run this, I received a…
jaredk
  • 986
  • 5
  • 21
  • 37
5
votes
2 answers

Is ReaderWriterLockSlim resistant to ThreadAbortException?

I would like to check whether following code is resistant against ThreadAbortException and will not lead into orphan lock. If it is not, what is the best pattern to avoid orphan locks here? ReaderWriterLockSlim _lock = new…
user2126375
  • 1,594
  • 12
  • 29
5
votes
3 answers

Can this unexpected behavior of PrepareConstrainedRegions and Thread.Abort be explained?

I was playing around with Constrained Execution Regions tonight to better round out my understanding of the finer details. I have used them on occasion before, but in those cases I mostly adhered strictly to established patterns. Anyway, I noticed…
Brian Gideon
  • 47,849
  • 13
  • 107
  • 150
5
votes
1 answer

LegacyUnhandledExceptionPolicy doesn't allow to catch (and swallow) ThreadAbortException?

I'm using .NET 1.1 compability mode for unhandled exception handling. The problem is that when LegacyUnhandledExceptionPolicy is set to "1" (which is what I want), I cannot catch and swallow ThreadAbortException. Example…
Borka
  • 2,169
  • 3
  • 20
  • 26
4
votes
4 answers

What is the recommended way to guard against resource leaks in the context of ThreadAbortException?

I'm working on improving the exception-safety of a piece of code and I realized that a raised ThreadAbortException may cause undesired resource leaks, even when guarding resources with the C# using construct. For instance, consider the following…
Steve Guidi
  • 19,700
  • 9
  • 74
  • 90
4
votes
1 answer

Getting "abort Exception" report from Play Store on MI devices

Getting abort exception on google play console for Xiaomi Mi A1 (tissot_sprout), Android 8.1 and Xiaomi Redmi Note 5 Pro (whyred), Android 8.1 devices only! *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** pid: 0, tid: 0 >>>…
4
votes
0 answers

Why is a finally block *sometimes* not executed on ThreadAbortException if it contains an await?

UPDATE: I don't think this question is a duplicate of Can ThreadAbortException skip finally? because (1) I'm not creating another thread, so there's no possibility of a race condition, and (2) this behavior only occurs if the finally block contains…
Michael Liu
  • 52,147
  • 13
  • 117
  • 150
4
votes
3 answers

"Exception thrown: 'System.Threading.ThreadAbortException' in mscorlib.dll" when using Response.Redirect()

In an OnClick method for a button in an ASP.NET web form I have a call to Response.Redirect() which causes the system to abort the thread with the error message: Exception thrown: 'System.Threading.ThreadAbortException' in mscorlib.dll There's a…
Joe Schofield
  • 69
  • 1
  • 1
  • 7
3
votes
2 answers

System.Threading.ThreadAbortException in System.Windows.Markup.WpfXamlLoader.Load when application is restarted

I have created an WPF application that starts on windows start. Application checks for list of files on the system and if any file is missing it popups the file path. The issue I am facing is when I restart the system while application is running,…
Sumit
  • 2,932
  • 6
  • 32
  • 54
1
2 3 4 5 6