Open a new form on the main thread

后端 未结 2 1751
萌比男神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
    
    0 讨论(0)
  • 2021-01-26 07:20

    Just use this

    Application.Run(new OppenMainForm());
    
    0 讨论(0)
提交回复
热议问题