Splash Screen waiting until thread finishes

前端 未结 5 705
醉梦人生
醉梦人生 2020-11-22 07:46

I still have a problem with the splash screen. I don\'t want to use the property SC.TopMost=true.

Now my application scenario is as follows:

5条回答
  •  攒了一身酷
    2020-11-22 08:29

    Same question, same answer:

    The .NET framework has excellent built-in support for splash screens. Start a new WF project, Project + Add Reference, select Microsoft.VisualBasic. Add a new form, call it frmSplash. Open Project.cs and make it look like this:

    using System;
    using System.Windows.Forms;
    using Microsoft.VisualBasic.ApplicationServices;
    
    namespace WindowsFormsApplication1 {
      static class Program {
        [STAThread]
        static void Main(string[] args) {
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
          new MyApp().Run(args);
        }
      }
      class MyApp : WindowsFormsApplicationBase {
        protected override void OnCreateSplashScreen() {
          this.SplashScreen = new frmSplash();
        }
        protected override void OnCreateMainForm() {
          // Do your time consuming stuff here...
          //...
          System.Threading.Thread.Sleep(3000);
          // Then create the main form, the splash screen will close automatically
          this.MainForm = new Form1();
        }
      }
    }
    

提交回复
热议问题