从非UI线程打开Windows窗体

Ale*_*tov 0 c#

如何从非UI线程正确打开Windows窗体?

I4V*_*I4V 5

var th = new Thread(() =>
{
    var form = new YourForm();  
    form.FormClosing += (s, e) => Application.ExitThread();
    form.Show();
    Application.Run();
});
th.SetApartmentState(ApartmentState.STA);
th.Start();
Run Code Online (Sandbox Code Playgroud)