zoukankan      html  css  js  c++  java
  • c# winform 欢迎界面时加载数据

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;
    
    namespace WindowsFormsApplication1
    {
        public partial class WelcomeForm : Form
        {
            public WelcomeForm()
            {
                InitializeComponent();
            }
    
            private void WelcomeForm_Load(object sender, EventArgs e)
            {
                //Thread.Sleep(2000);
                //this.Close();
                //this.Dispose();
            }
    
            public void KillMe(object o, EventArgs e)
            {
                this.Close();
            }
    
            /// <summary>
            /// 加载并显示主窗体
            /// </summary>
            /// <param name="form">主窗体</param>
            public static void LoadAndRun(Form form)
            {
                //订阅主窗体的句柄创建事件
                form.HandleCreated += delegate
                {
                    //启动新线程来显示Splash窗体
                    new Thread(new ThreadStart(delegate
                    {
                        WelcomeForm splash = new WelcomeForm();
                        //订阅主窗体的Shown事件
                        form.Shown += delegate
                        {
                            //通知Splash窗体关闭自身
                            splash.Invoke(new EventHandler(splash.KillMe));
                            splash.Dispose();
                        };
                       // Thread.Sleep(2000);
                        //显示Splash窗体
                        Application.Run(splash);
                    })).Start();
                };
                //显示主窗体
                Application.Run(form);
            }
    
        }
    }
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                //Thread.Sleep(2000);
                for (int i = 0; i < 100; i++)
                {
                    Thread.Sleep(100);
                }
                //this.Focus();
                MessageBox.Show("加载完毕!");
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Forms;
    using System.Threading;
    
    namespace WindowsFormsApplication1
    {
        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
    
                WelcomeForm.LoadAndRun(new Form1());
            }
        }
    }
  • 相关阅读:
    pat 甲级 1065. A+B and C (64bit) (20)
    pat 甲级 1064. Complete Binary Search Tree (30)
    pat 甲级 1010. Radix (25)
    pat 甲级 1009. Product of Polynomials (25)
    pat 甲级 1056. Mice and Rice (25)
    pat 甲级 1078. Hashing (25)
    pat 甲级 1080. Graduate Admission (30)
    pat 甲级 团体天梯 L3-004. 肿瘤诊断
    pat 甲级 1099. Build A Binary Search Tree (30)
    Codeforce 672B. Different is Good
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3361511.html
Copyright © 2011-2022 走看看