/// <summary> /// 所有任务执行完毕:执行关机任务 /// </summary> public void AllFinished(object e) { if (this.InvokeRequired) { this.Invoke(new AcTaskDelegate(AllFinished), e); return; } ShutdownType action = ShutdownType.None; //执行关机任务 switch (cboAfterComplete.SelectedIndex) { case 0: //无动作 action = ShutdownType.None; break; case 1: //关机 action = ShutdownType.Shutdown; break; case 2: //待机 action = ShutdownType.Suspend; break; case 3: //休眠 action = ShutdownType.Hibernate; break; case 4: //注销 action = ShutdownType.Logoff; break; case 5: //重启 action = ShutdownType.Reboot; break; case 6: //退出程序 action = ShutdownType.ExitProgram; break; } if (action == ShutdownType.ExitProgram) { mnuTrayExit_Click(this, EventArgs.Empty); } else if (action != ShutdownType.None && !Tools.IsRunningOnMono) { FormShutdown frm = new FormShutdown(action); frm.ShowDialog(); } }
/// <summary> /// 执行下一个任务,如果所有任务执行完毕则执行关机任务 /// </summary> public void ProcessNext() { //执行下一个可能开始的任务 taskMgr.ContinueNext(); //如果没有正在等待的任务了且正在运行的任务为0 if (taskMgr.GetNextWaiting() == null && taskMgr.GetRunningCount() == 0) { ShutdownType action = ShutdownType.None; //执行关机任务 switch (cboAfterComplete.SelectedIndex) { case 0: //无动作 action = ShutdownType.None; break; case 1: //关机 action = ShutdownType.Shutdown; break; case 2: //待机 action = ShutdownType.Suspend; break; case 3: //休眠 action = ShutdownType.Hibernate; break; case 4: //注销 action = ShutdownType.Logoff; break; case 5: //重启 action = ShutdownType.Reboot; break; case 6: //退出程序 action = ShutdownType.ExitProgram; break; } if (action == ShutdownType.ExitProgram) { mnuTrayExit_Click(this, EventArgs.Empty); } if (action != ShutdownType.None) { FormShutdown frm = new FormShutdown(action); frm.ShowDialog(); } } }