Skip to content

Remove deprecated Thread.Abort from "Pausing and interrupting threads"#51835

Merged
meaghanlewis merged 4 commits intomainfrom
copilot/remove-deprecated-abort-method
Feb 25, 2026
Merged

Remove deprecated Thread.Abort from "Pausing and interrupting threads"#51835
meaghanlewis merged 4 commits intomainfrom
copilot/remove-deprecated-abort-method

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

Updates the "Pausing and interrupting threads" article to stop recommending the deprecated Thread.Abort API in code examples, while retaining informational references to .NET Framework-only behavior.

Changes

  • Code snippets: Migrated from legacy ~/samples/snippets/ to ./snippets/pausing-and-resuming-threads/{csharp|vb}/, targeting net10.0. The example now demonstrates only Thread.Interrupt (not Thread.Abort).
  • Article prose: Removed Thread.Abort as a suggested way to wake a sleeping thread; the Thread.Sleep(Timeout.Infinite) paragraph now references only Thread.Interrupt.
  • Managed-wait section: Restored as a bullet list with a .NET Framework only note clarifying that Thread.Abort / ThreadAbortException still applies in .NET Framework, while the main recommendation uses Thread.Interrupt.
  • Thread.Join explanation: Added a sentence after the code example describing that Thread.Join blocks the calling thread until the interrupted thread finishes execution.
  • Snippet references: Updated from legacy [!code-csharp[...]] syntax to :::code language="csharp"...::: format.
  • See Also: Restored ThreadAbortException xref; added link to Canceling threads cooperatively.
  • Deleted the now-unused legacy snippet files under samples/snippets/csharp/VS_Snippets_CLR/Conceptual.Threading.Resuming/ and samples/snippets/visualbasic/VS_Snippets_CLR/Conceptual.Threading.Resuming/.
Original prompt

This section details on the original issue you should resolve

<issue_title>Example and description using deprecated Abort method</issue_title>
<issue_description>The "Pausing and interrupting threads" page suggests using Thread.Abort, which is deprecated.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

<agent_instructions>Don't use the deprecated Thread.Abort method</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Internal previews

📄 File 🔗 Preview link
docs/standard/threading/pausing-and-resuming-threads.md docs/standard/threading/pausing-and-resuming-threads

…cle and snippets

Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com>
Copilot AI changed the title [WIP] Update thread documentation to remove deprecated Abort method Remove deprecated Thread.Abort from "Pausing and interrupting threads" Feb 20, 2026
Copilot AI requested a review from meaghanlewis February 20, 2026 22:47
@meaghanlewis
Copy link
Contributor

@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>
Copy link
Contributor Author

Copilot AI commented Feb 20, 2026

@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 me...

Added a sentence after the code example (commit a264e20): "The example calls Thread.Join to block the calling thread until the interrupted thread finishes execution."

@meaghanlewis meaghanlewis marked this pull request as ready for review February 20, 2026 23:21
@meaghanlewis meaghanlewis requested review from a team and BillWagner as code owners February 20, 2026 23:21
Copilot AI review requested due to automatic review settings February 20, 2026 23:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Abort and ThreadAbortException.
  • Added new C# and Visual Basic snippet projects (targeting net10.0) demonstrating Thread.Interrupt, plus Thread.Join to wait for completion.
  • Updated the article to remove Thread.Abort references, switch to :::code::: snippet inclusion, and add an ai-usage disclosure.

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.

…ion See Also entry

Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com>
@meaghanlewis meaghanlewis merged commit 320b23c into main Feb 25, 2026
13 checks passed
@meaghanlewis meaghanlewis deleted the copilot/remove-deprecated-abort-method branch February 25, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example and description using deprecated Abort method

4 participants