110,534
社区成员
发帖
与我相关
我的任务
分享
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Main.WaitForm sp = new Main.WaitForm(); //启动窗体---为等待窗口,显示正在加载窗体。、
context = new ApplicationContext();
context.Tag = sp;
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
Application.Idle += new EventHandler(Application_Idle); //程序运行空闲去执行主程序窗体相应初始化代码
sp.Show(); //显示启动窗体
Application.Run(context);
}
private static void Application_Idle(object sender, EventArgs e)
{
Application.Idle -= new EventHandler(Application_Idle);
Start();
}
private static void Start()
{
if (context.MainForm == null)
{
//启动主程序窗体
Main.MainDesktop mw = Main.MainDesktop();
context.MainForm = mw;
mw.Initialization_All();
mw.Show();
//如果加载完毕,则关闭启动窗体
Main.WaitForm sp = context.Tag as Main.WaitForm;
if (sp != null)
{
sp.Close();
}
}
}
private void BackWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
PicBox.Visible = false;
tlp1.Visible = true;
}
private void BackWorker_DoWork(object sender, DoWorkEventArgs e)
{
//要执行的动作
}
private void button1_Click(object sender,EventArgs e)
{
BackWorker.RunWorkerAsync();
}