What can cause issues when thread is aborted?
I need to use Thread.Abort()
in my code because the thread runs complex code that have a lot of loops, objects and conditions.
I know that Thread.Abort()
can lead to deadlock when using Monitor
, also it can prevent resources from being released, but I can handle these problems.
I use IDisposable
/using
pattern or catch ThreadAbortException
to guarantee that all resources are released and asynchronous operations are stopped.
The application seems to works fine now. But, since the code is pretty complex, I'm not sure if there could be some rare cases when aborting the thread can lead to memory leaks or unhandled exceptions.
Is there any .net classes (e.g. FileStream
, Dictionary
) that can cause problems if thread is aborted when their code are executed? Or some other issues that I should be aware of?