Open a new form on the main thread

后端 未结 2 1775
萌比男神i
萌比男神i 2021-01-26 06:27

How can I open a new form from the main thread in C#?

At this moment I open them by using this:

System.Threading.Thread t = new System.Threading.Thread(n         


        
2条回答
  •  半阙折子戏
    2021-01-26 07:07

    Go to your program.cs file and alter it so that you show your login form and then, after it has been closed, determine if you should open up another form:

    It'll likely look something more or less like this:

    LoginForm loginform = new LoginForm();
    Application.Run(loginform);
    
    if (loginform.DialogResult == DialogResult.Yes)
        Application.Run(new MainForm());
    //TODO handle error cases
    

提交回复
热议问题