Beispiel #1
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     if (TaskQueue.GeTaskQueue().GetTaskCount() != 0)
     {
         if (MessageBox.Show("还有运行在后台的紧凑任务,是否关闭程序?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             TaskQueue.GeTaskQueue().IsRunning = false;
             Thread.Sleep(500);
             this.Close();
             Process.GetCurrentProcess().Kill();
         }
     }
 }
Beispiel #2
0
 private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (TaskQueue.GeTaskQueue().GetTaskCount() != 0)
     {
         if (MessageBox.Show("还有运行在后台的紧凑任务,是否关闭程序?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             log.Info("程序退出");
             TaskQueue.GeTaskQueue().IsRunning = false;
             Thread.Sleep(500);
             Process.GetCurrentProcess().Kill();
         }
         else
         {
             e.Cancel = true;
         }
     }
     else
     {
         log.Info("程序退出");
         TaskQueue.GeTaskQueue().IsRunning = false;
         Thread.Sleep(50);
         Process.GetCurrentProcess().Kill();
     }
 }