Abort a Thread started with Delegate.BeginInvoke

.net, c#, delegates, multithreading, vb.net

Solution

The only way to do that would be to have the delegate pass its `Thread.CurrentThread` to the main thread.

However, you should not do it; terminating ThreadPool threads is not a good idea. (Unless you cancel the abort in a `catch` block)

You'll have to use your own threads.

Problem

Disclaimer: I know that `Thread.Abort` is evil. I'm using it as a last resort since some I/O functions (e.g., `File.Exists` when used on a non-existing network share) block for a large amout of time and do not allow you to specify a timeout. Question: Is it possible to Abort (as in `Thread.Abort`) a worker thread started using `Delegate.BeginInvoke` or do I have to do the Thread handling myself?

Original source