开发者

Control init lag at startup

开发者 https://www.devze.com 2023-01-03 02:56 出处:网络
I get a small lag at the 开发者_JAVA技巧controls I\'m using when I start up my app. Can I show the main form after the controls are drawn?Try subscribing to the Application.Idle event inside your form

I get a small lag at the 开发者_JAVA技巧controls I'm using when I start up my app. Can I show the main form after the controls are drawn?


Try subscribing to the Application.Idle event inside your form's load method, and unsubscribing from it once invoked. Like this:

public Form()
{
    InitializeComponent();
}

private void Form_Load(object sender, EventArgs e)
{
    Application.Idle += new EventHandler(Application_Idle);
    // any loading prep code here
}

private void Application_Idle(object sender, EventArgs e)
{
    Application.Idle -= new EventHandler(Application_Idle);
    // additional code here, which is executed *after* controls are visible and loaded
}
0

精彩评论

暂无评论...
验证码 换一张
取 消