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.
Thread.Abortis a lot safer than it used to be for the following reasons.finallyblocks to execute.However, there is still a problem with exactly when the
ThreadAbortExceptiongets injected. Consider this code.If this code were running on a 32-bit platform the
valuevariable could be corrupted ifThread.Abortwas called and theThreadAbortExceptionwere injected in the middle of the write tovalue. SinceDateTimeis 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
finallyblock 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 afinallyblock.