public int timeptr = 0; //时间标记:数字则代表频号 /// <summary> /// 程序关闭响应事件 /// 1.clock用于检测相对应的异常退出操作 /// 2.程序暂停、程序正在运行、程序自动运行过程中不允许关闭程序 /// 3.程序自动运行关闭条件和时间锁有关,若时间锁锁上则意味着程序正在自动运行 /// </summary> private void calc_FormClosing(object sender, FormClosingEventArgs e) { NewMain.Nform.logClass.write("执行calc_FormClosing函数"); cloud.writexml(); int clock = 0; if (NewMain.Nform.cloud.Calc == null) { return; } if (NewMain.Nform.cloud.Calc.button1.Text == "继续" && NewMain.Nform.cloud.Calc.buttonOperate.Enabled == false && NewMain.Nform.cloud.Calc.buttonOperate.Text == "结束" && clock == 0) { clock = 2; DialogResult result = MessageBox.Show("小云发现程序已经暂停,请点击继续后结束程序", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.OK) { e.Cancel = true; //点击OK return; } else { e.Cancel = true; return; } } if (NewMain.Nform.cloud.Calc.buttonOperate.Text == "结束" && clock == 0) { DialogResult result = MessageBox.Show("小云检测到计算过程尚未结束,关闭请点击结束按钮!", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.OK) { e.Cancel = true; //点击OK return; } else { e.Cancel = true; return; } } if (time == true) { DialogResult result = MessageBox.Show("小云正在控制程序请勿关闭!", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.OK) { e.Cancel = true; //点击OK return; } else { e.Cancel = true; return; } } }
void exit() { cloud.writexml(); }