title: How to get a thread handle to pass to CancelSynchronousIO?
body: <p>Creating a background thread in C# in the normal way - </p>
  
  <pre><code>Thread t = new Thread(....);
  t.IsBackground = true;
  t.Start();
  etc etc
  </code></pre>
  
  <p>Wanting to call <code>CancelSynchronousIO</code> 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:</p>
  
  <pre><code>[DllImport("kernel32.dll", SetLastError=true)]
  static extern bool CancelSynchronousIo(IntPtr threadHandle);
  </code></pre>
  
  <p>There seems to be various ways of getting a thread ID, but not a handle?  And the ways of getting a thread ID seem to give you an ID only within the managed environment, so no use for PInvoke calls?  I'm guessing I'm missing something.</p>
  
  <p>Do I need to do other PInvoke calls to get the thread handle or is there an easier way?</p>