Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6357863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:15:16+00:00 2026-05-24T23:15:16+00:00

MSDN on migrating legacy multithreaded applications (from this page on exception handling in threads):

  • 0

MSDN on migrating legacy multithreaded applications (from this page on exception handling in threads):

In general, the change will expose previously unrecognized programming problems so that they can be fixed. In some cases, however, programmers might have taken advantage of the runtime backstop, for example to terminate threads. Depending on the situation, they should consider one of the following migration strategies:

Restructure the code so the thread exits gracefully when a signal is received.

Use the Thread.Abort method to abort the thread.

If a thread must to be stopped so that process termination can proceed, make the thread a background thread so that it is automatically terminated on process exit.

In all cases, the strategy should follow the design guidelines for exceptions. See Design Guidelines for Exceptions.

This suggests that using Thread.Abort is an appropriate way to terminate a thread. Has something changed while I wasn’t looking? The last I’d heard was this could cause unexpected behaviours so shouldn’t be used.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:15:17+00:00Added an answer on May 24, 2026 at 11:15 pm

    Thread.Abort is a lot safer than it used to be for the following reasons.

    • The runtime will defer aborts while execution is in unmanaged code.
    • The abort will allow finally blocks to execute.

    However, there is still a problem with exactly when the ThreadAbortException gets injected. Consider this code.

    public class Example
    {
      private DateTime value = DateTime.MinValue;
    
      public void DoSomething()
      {
        try
        {
          value = DateTime.UtcNow;
        }
        finally
        {
        }
      }
    }
    

    If this code were running on a 32-bit platform the value variable could be corrupted if Thread.Abort was called and the ThreadAbortException were injected in the middle of the write to value. Since DateTime is 8 bytes the write has to take place using more than one instruction.

    It is possible to guard against this by placing critical code in a finally block and by using Constrained Execution Regions, but it would be incredibly difficult to get right for all but the simplest types your define. And even then you cannot just put everything in a finally block.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MSDN is a nice place to get vague, general information on this, with just
MSDN documentation indicates that threads started by the TPL will enjoy better scheduling. However,
MSDN states that: Background threads are identical to foreground threads with one exception: a
Per MSDN , In SQL Server, the page size is 8 KB. This means
MSDN docs say that only value types need boxing, but this does not apply
We are migrating a .Net windows application to Windows 7. This application can be
I am following the steps listed here: http://msdn.microsoft.com/en-us/library/dd483478.aspx at the bottom of that page
MSDN says http://msdn.microsoft.com/en-us/library/ms256086.aspx degree[@from != Harvard] - All elements where the from attribute is
The MSDN gives this code example in the article on the Func Generic Delegate
msdn: Any public static (Shared in Visual Basic) members of this type are thread

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.