How to open a form in a thread and force it to stay open

前端 未结 6 1322
栀梦
栀梦 2021-01-02 10:40

I am still having problems with figuring out how to create winforms in a separate UI thread that I discussed here.

In trying to figure this out I wrote the following

6条回答
  •  一整个雨季
    2021-01-02 11:02

    private void button1_Click(object sender, EventArgs e)
    {
        var t = new Thread(RunNewForm);
        t.Start();
    }
    public static void RunNewForm()
    {
         Application.Run(new Form2());
    }
    

提交回复
热议问题