Skip to content

Comments

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

Open
Copilot wants to merge 3 commits intomainfrom
copilot/remove-deprecated-abort-method
Open

Remove deprecated Thread.Abort from "Pausing and interrupting threads"#51835
Copilot wants to merge 3 commits intomainfrom
copilot/remove-deprecated-abort-method

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

  • Create new C# snippet in snippets/pausing-and-resuming-threads/csharp/ showing only Thread.Interrupt (no Thread.Abort)
  • Create new VB snippet in snippets/pausing-and-resuming-threads/vb/ with the same change
  • Update pausing-and-resuming-threads.md to remove Thread.Abort references from prose and bullet points
  • Update article snippet references from legacy [!code-...] to modern :::code::: format
  • Remove ThreadAbortException from See Also section; added link to cooperative cancellation article
  • Delete old legacy snippet files (only referenced in this article)
  • Verified C# and VB snippets compile successfully (net10.0)
  • Verified C# example produces correct output
  • Add sentence after code example describing what Thread.Join does
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.


- <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).
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we keep the .NET Framework info?

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

3 participants