Making a splash screen

前端 未结 6 1197
无人及你
无人及你 2021-01-06 06:29

The concept of a splash screen doesn\'t strike me as something that should be so complicated, but I\'m having trouble getting the whole splash screen painted.

Let\'s

6条回答
  •  温柔的废话
    2021-01-06 07:06

    You can use the await command with .Net Framework 4.5 Your form will not be visible until the task is completed

        private void YourForm_Load(object sender, EventArgs e)
        {
            //call SplashScreen form
            SplashScreen splash = new SplashScreen();
            splash.Show();
            Application.DoEvents();
            //Run your long task while splash screen is displayed i.e. loadAndCheckDatabase
            Task processLongTask = loadAndCheckDatabase();
            //wait for the task to be completed
            processLongTask.Wait();
            splash.Close();
    
            //...
        }
    

提交回复
热议问题