Closing a form during a constructor

前端 未结 9 2045
面向向阳花
面向向阳花 2020-12-01 11:59

Is it possible to close a form while the constructor is executing (or simply to stop it showing at this stage)?

I have the following code:

public par         


        
9条回答
  •  伪装坚强ぢ
    2020-12-01 12:07

    Environment.Exit(...) is working for me (without window flickering):

    public partial class MyForm : Form
    {        
        public MyForm()
        {
            if (weShouldClose)
            {
                Environment.Exit(0);
            }
        }
    }
    

提交回复
热议问题