Remove deprecated Thread.Abort from "Pausing and interrupting threads"#51835
Remove deprecated Thread.Abort from "Pausing and interrupting threads"#51835
Conversation
…cle and snippets Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com>
|
@copilot can you add a sentence describing what the Thread.Join method does: https://review.learn.microsoft.com/dotnet/api/system.threading.thread.join?view=net-10.0&branch=main in the Thread.Sleep method section. |
Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com>
Added a sentence after the code example (commit a264e20): "The example calls |
There was a problem hiding this comment.
Pull request overview
This PR updates the “Pausing and interrupting threads” documentation to stop recommending or demonstrating the deprecated Thread.Abort API, replacing it with Thread.Interrupt-only examples and modern snippet inclusion.
Changes:
- Removed legacy snippet files that used
Thread.AbortandThreadAbortException. - Added new C# and Visual Basic snippet projects (targeting
net10.0) demonstratingThread.Interrupt, plusThread.Jointo wait for completion. - Updated the article to remove
Thread.Abortreferences, switch to:::code:::snippet inclusion, and add anai-usagedisclosure.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| samples/snippets/csharp/VS_Snippets_CLR/Conceptual.Threading.Resuming/cs/Sleep1.cs | Deletes the legacy sample that used Thread.Abort. |
| samples/snippets/csharp/VS_Snippets_CLR/Conceptual.Threading.Resuming/cs/Project.csproj | Removes the legacy snippet project file associated with the deleted sample. |
| docs/standard/threading/snippets/pausing-and-resuming-threads/csharp/InterruptThread/Program.cs | Adds a new C# example demonstrating Thread.Interrupt and Thread.Join. |
| docs/standard/threading/snippets/pausing-and-resuming-threads/csharp/InterruptThread/InterruptThread.csproj | Adds a new C# snippet project targeting net10.0. |
| docs/standard/threading/snippets/pausing-and-resuming-threads/vb/InterruptThread/Program.vb | Updates the VB example to remove Thread.Abort, and uses Join after Interrupt. |
| docs/standard/threading/snippets/pausing-and-resuming-threads/vb/InterruptThread/InterruptThread.vbproj | Adds a new VB snippet project targeting net10.0. |
| docs/standard/threading/pausing-and-resuming-threads.md | Removes Thread.Abort mentions, updates snippet references to :::code:::, adds Thread.Join explanation, and adds ai-usage. |
|
|
||
| - <xref:System.Threading.Thread.Interrupt%2A?displayProperty=nameWithType> wakes a thread out of any wait it might be in and causes a <xref:System.Threading.ThreadInterruptedException> to be thrown in the destination thread. | ||
|
|
||
| - .NET Framework only: <xref:System.Threading.Thread.Abort%2A?displayProperty=nameWithType> wakes a thread out of any wait it might be in and causes a <xref:System.Threading.ThreadAbortException> to be thrown on the thread. For details, see [Destroy threads](destroying-threads.md). |
There was a problem hiding this comment.
Should we keep the .NET Framework info?
snippets/pausing-and-resuming-threads/csharp/showing onlyThread.Interrupt(noThread.Abort)snippets/pausing-and-resuming-threads/vb/with the same changepausing-and-resuming-threads.mdto removeThread.Abortreferences from prose and bullet points[!code-...]to modern:::code:::formatThreadAbortExceptionfrom See Also section; added link to cooperative cancellation articleThread.JoindoesOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Internal previews