How do I get the GUI thread of winform?

All GUI elements in Windows Forms are typically done on a single thread. I strongly recommend avoiding trying to do this any other way.

You can always marshal code to that thread by using Control.Invoke or Control.BeginInvoke with any Control.

If you really want to get the thread's ID (not sure what use this will be..?), you could use:

int GetControlThreadId(Control control)
{
    int threadId;
    control.Invoke( new Action( () => 
       {
           threadId = Thread.CurrentThread.ManagedThreadId;
       }));
    return threadId;
}

If your code is not in a form or control, you can use

if (System.Windows.Forms.Form.ActiveForm.InvokeRequired)
{
    System.Windows.Forms.Form.ActiveForm.Invoke(...);
}

This should do it, however I agree with other posters that this is probably the wrong thing to do for other reasons...

var thatWindowsThread = (Thread)(WhateverWindow.Invoke(()=>Thread.CurrentThread);