private void FrmMain_Load(object sender, EventArgs e) { CheckConnection(); //检查网络连接 UpdateSever us = new UpdateSever("http://blog.sina.com.cn/s/blog_a62456420101vkbb.html", "Get", null, GetVersion, Version, false); us.Updating(); timer_chkUpdate.Start(); //版本检测计时器 }
public delegate void MessageBoxHandler(); //交回主线程的委托 private void backgroundWorker_chkUpdate_DoWork(object sender, DoWorkEventArgs e) //检查版本后台线程 { UpdateSever us = new UpdateSever("http://blog.sina.com.cn/s/blog_a62456420101vkbb.html", "Get", null, GetVersion, Version, false); if (us.GetUpdateVersionInfo.Stopusing == "否") { return; } else { //主线程出现模式对话框 this.Invoke(new MessageBoxHandler(delegate() { btn_stop_Click(this, new EventArgs()); MessageBox.Show("管理员被师姐拉走了.....\n萌萌哒下次再见!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); Process.Start("http://weibo.com/HKJOVI"); Process.GetCurrentProcess().Kill(); })); } }
//检查版本后台线程 //交回主线程的委托 private void backgroundWorker_chkUpdate_DoWork(object sender, DoWorkEventArgs e) { UpdateSever us = new UpdateSever("http://blog.sina.com.cn/s/blog_a62456420101vkbb.html", "Get", null, GetVersion, Version, false); if (us.GetUpdateVersionInfo.Stopusing == "否") { return; } else { //主线程出现模式对话框 this.Invoke(new MessageBoxHandler(delegate() { btn_stop_Click(this, new EventArgs()); MessageBox.Show("管理员被师姐拉走了.....\n萌萌哒下次再见!","提示",MessageBoxButtons.OK, MessageBoxIcon.Error); Process.Start("http://weibo.com/HKJOVI"); Process.GetCurrentProcess().Kill(); })); } }