/// <summary> /// 后台线程执行函数。只负责打开数据库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dbBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { try { database.OpenConnection(); this.dbBackgroundWorker.ReportProgress(100); //报告执行完毕,执行RunWorkerCompleted } catch (Exception ex) { ExceptionForm.ShowDialog(ex); } }
private void 卸载ToolStripMenuItem_Click(object sender, EventArgs e) { try { File.Delete(Properties.Resources.RecorderShellFullFilename); MessageBox.Show("插件已经卸载", "成功!"); } catch (Exception e1) { ExceptionForm.ShowDialog(e1); } }
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { ExceptionForm.ShowDialog((Exception)e.ExceptionObject); }
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { ExceptionForm.ShowDialog(e.Exception); }
private void button确定_Click(object sender, EventArgs e) { try { float comboBoxTimeMinutes = float.Parse(this.comboBoxTime.Text); if (this.label设置倒计时.Text.Contains("小时")) { comboBoxTimeMinutes *= 60; } if (this.记录关机时间checkBox.Checked && this.comboBoxMode.Text != "延缓") { SqlExecuter.记录关机事件(); } if (comboBoxTimeMinutes < 0) // 如果小于0,说明只是记录时间就可以推出 { return; } CancelShutdownCommand(); try { switch (this.comboBoxMode.Text) { case "关机": float seconds = comboBoxTimeMinutes * 60; RunShutdownCommand(Mode.关机, seconds); break; case "重启": if (!this.记录关机时间checkBox.Checked) { File.CreateText(@"C:\Users\" + ProgramLauncher.SystemUserName + @"\DONOTWRITEDATA").Close(); } RunShutdownCommand(Mode.重启, comboBoxTimeMinutes * 60); break; case "休眠": Run休眠或睡眠("休眠", comboBoxTimeMinutes); break; case "延缓": FastModeExecutor.ShutdownWithSeconds_DelayMode((int)(comboBoxTimeMinutes * 60)); break; case "睡眠": Run休眠或睡眠("睡眠", comboBoxTimeMinutes); break; } } catch (FormatException) { MessageBox.Show("请输入正确的数据!", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Error); this.comboBoxTime.Text = "0"; return; } } catch (Exception ex) { ExceptionForm.ShowDialog(ex); } }