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());
            }
        }
    }
  • 相关阅读:
    Dubbo 节点telnet测试
    node.js 文件下载
    node.js获取ip及mac
    excel中根据A列筛选B列填充C列
    django在读取数据库时未筛选到符合条件的记录会报错
    django分页功能
    django中命令行调试程序
    Python中if-else的多种写法
    python自定义函数的参数之四种表现形式
    python类变量和实例变量的区别
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3361511.html
Copyright © 2011-2022 走看看