Thread.Abort much safer than before, for the following reasons.
- The runtime will postpone the interrupt while execution is in unmanaged code.
- Cancel will allow the execution of
finallyblocks.
However, there is still a problem with when introduced ThreadAbortException. Consider this code.
public class Example
{
private DateTime value = DateTime.MinValue;
public void DoSomething()
{
try
{
value = DateTime.UtcNow;
}
finally
{
}
}
}
32- , value , Thread.Abort, ThreadAbortException value. DateTime - 8 , .
, finally , , , . finally.