日期:2014-05-18 浏览次数:20859 次
namespace ShiftConnect.UI { public partial class Mainform : Form { public Mainform() { //thread to show splash screen Thread threadLoading = new Thread(new ThreadStart(splashscreen)); threadLoading.Name = "Splash UI"; threadLoading.Priority = ThreadPriority.Normal;//定义级别 threadLoading.IsBackground = true;//定义是否后台线程 threadLoading.Start();//启动线程 InitializeComponent(); } /// <summary> /// 窗口创建事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Mainform_Load(object sender, EventArgs e) { if (AccessHelp.conntrue() == false) { MessageBox.Show("数据库连接失败!\r\n请查看数据库是否存在或者连接字符串是否正确", "提示"); this.Close(); } else { SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.lable1.Text = "正在读取WheelChange信息......"; })); Thread.Sleep(1000); Form_load();//载入CO2和wheelchange信息 SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.lable1.Text = "正在读取交接事项信息......"; })); Thread.Sleep(1000); ShiftconnRefush();//载入交接事项 SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.lable1.Text = "正在读取B/L设备信息......"; })); Thread.Sleep(1000); equipinfor();//载入设备信息 SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.lable1.Text = "正在读取设备菜单......"; })); Thread.Sleep(1000); EvelauteMenu();//为cmb_pcLine装载下拉菜单 SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.lable1.Text = "正在读取CO2库存信息......"; })); Thread.Sleep(1000); co2load();//装载co2设备菜单 Thread.Sleep(3000); SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.Dispose(); })); this.WindowState = FormWindowState.Normal; } } /// <summary> /// 定义splash screen /// </summary> public static void splashscreen() { SplashForm = new Login(); Application.Run(SplashForm); } public static Login SplashForm { get; set; }