I'm porting a project to .NET Core and have some logic with the method. Do you know .NET Core supports Abort()
method in Thread class?
If Abort is called on a managed thread while it is executing unmanaged code, a ThreadAbortException is not thrown until the thread returns to managed code. If two calls to Abort come at the same time, it is possible for one call to set the state information and the other call to execute the Abort .
If the Abort method is called on a thread which has not been started, then that thread will abort when Start is called. If the Abort method is called on a thread which is blocked or is sleeping then the thread will get interrupted and after that get aborted.
ThreadAbortException is a special exception that can be caught, but it will automatically be raised again at the end of the catch block. When this exception is raised, the runtime executes all the finally blocks before ending the thread.
When a call is made to the Abort method to destroy a thread, the common language runtime throws a ThreadAbortException. ThreadAbortException is a special exception that can be caught, but it will automatically be raised again at the end of the catch block.
Thread.Abort has been removed in .NET Core.
As far as I have understood so far it is now recommended to use CancellationToken. Please read more about how to use this here:
https://msdn.microsoft.com/en-us/library/dd997364(v=vs.110).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With