I have an unmanaged DLL with a function that can run for a long time if the input parameter is a large value, sometimes that is desirable but not always.
How can I i
From the MSDN
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.
So it seems, aborting the managed thread is not possible.
As an alternative you could try starting an unmanaged thread with Win32 APIs CreateThread(), WaitForSingleObject() and TerminateThread(). Use the signatures from here.
I didn't try this myself, but it surely introduces some risks, as you can not determine at which point of execution you are killing the thread. It might also lead to resource leaks. MSDN lists some of the side effects on the TerminateThread() reference.
In general I would advise against this kind of interruption. Maybe you have the possibility to change the unmanaged DLL to allow for a graceful abort.