Skip to content

Commit 6598356

Browse files
JeremyKuhnemairaw
andcommitted
Clarify ThreadAbortException on Core (dotnet#2823)
* Clarify ThreadAbortException on Core Call out that while the exception exists on .NET Core, it will never get thrown. * Update xml/System.Threading/ThreadAbortException.xml Co-Authored-By: Maira Wenzel <mairaw@microsoft.com>
1 parent d4dd4f7 commit 6598356

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

xml/System.Threading/ThreadAbortException.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
## Remarks
4343
When a call is made to the <xref:System.Threading.Thread.Abort%2A> method to destroy a thread, the common language runtime throws a <xref:System.Threading.ThreadAbortException>. <xref:System.Threading.ThreadAbortException> is a special exception that can be caught, but it will automatically be raised again at the end of the `catch` block. When this exception is raised, the runtime executes all the `finally` blocks before ending the thread. Because the thread can do an unbounded computation in the `finally` blocks or call <xref:System.Threading.Thread.ResetAbort%2A?displayProperty=nameWithType> to cancel the abort, there is no guarantee that the thread will ever end. If you want to wait until the aborted thread has ended, you can call the <xref:System.Threading.Thread.Join%2A?displayProperty=nameWithType> method. <xref:System.Threading.Thread.Join%2A> is a blocking call that does not return until the thread actually stops executing.
4444
45+
**.NET Core only:** Even though this type exists in .NET Core, since <xref:System.Threading.Thread.Abort%2A> is not supported, the common language runtime won't ever throw <xref:System.Threading.ThreadAbortException>.
46+
4547
> [!NOTE]
4648
> When the common language runtime (CLR) stops background threads after all foreground threads in a managed executable have ended, it does not use <xref:System.Threading.Thread.Abort%2A?displayProperty=nameWithType>. Therefore, you cannot use <xref:System.Threading.ThreadAbortException> to detect when background threads are being terminated by the CLR.
4749
@@ -137,4 +139,4 @@ Main ending.
137139
</Docs>
138140
</Member>
139141
</Members>
140-
</Type>
142+
</Type>

0 commit comments

Comments
 (0)