Exemple #1
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     while (true)
     {
         try
         {
             string log = BatchServiceClient.FetchLog();
             if (string.IsNullOrEmpty(log))
             {
                 Thread.Sleep(1000);
                 TaskbarManager.Instance.SetProgressValue(BatchServiceClient.progress, 100);
                 pbJobProgress.Invoke((MethodInvoker) delegate() { pbJobProgress.Value = BatchServiceClient.progress; });
                 if (!BatchServiceClient.IsRunning())
                 {
                     TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress);
                 }
             }
             else
             {
                 tbLogs.Invoke((MethodInvoker) delegate() { tbLogs.AppendText(log + "\n"); });
             }
         }
         catch
         {
             break;
         }
     }
 }
Exemple #2
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (BatchServiceClient.IsRunning())
     {
         DialogResult res = MessageBox.Show("Do you want to terminate job before quit?", "Info", MessageBoxButtons.YesNoCancel);
         if (res == System.Windows.Forms.DialogResult.Cancel)
         {
             e.Cancel = true;
         }
         else if (res == System.Windows.Forms.DialogResult.Yes)
         {
             BatchServiceClient.Terminate();
         }
     }
 }