How to get a thread handle to pass to CancelSynchronousIO?
问题 Creating a background thread in C# in the normal way - Thread t = new Thread(....); t.IsBackground = true; t.Start(); etc etc Wanting to call CancelSynchronousIO from the main thread to cancel a blocking IO call on the background thread. Don't know how to get a thread handle in the form of an IntPtr to pass to the function: [DllImport("kernel32.dll", SetLastError=true)] static extern bool CancelSynchronousIo(IntPtr threadHandle); There seems to be various ways of getting a thread ID, but not