Example #1
0
 public void StopTask()
 {
     taskFiles = new TaskFiles();
     for (int i = 0, l = processIds.Length; i < l; i++)
     {
         try
         {
             if (processIds[i] != 0)
             {
                 Process.GetProcessById(processIds[i]).Kill();
             }
             processIds[i] = 0;
         }
         catch (ArgumentException e)
         {
             Debug.WriteLine("Maybe the process [" + processIds[i] + "] isn't running. Exception message: " + e.Message);
         }
         catch (Win32Exception e)
         {
             MessageBox.Show(
                 "Can't kill the process [" + processIds[i] + "] . You can try again. Exception message: " + e.Message,
                 QueryLangDict("Message_Title_Error")
                 );
         }
     }
 }
Example #2
0
        private async void StartTaskButton_Click(object sender, RoutedEventArgs e)
        {
            if (UiData.TaskRunning)
            {
                StopTask();
            }
            else if (CheckConfig())
            {
                UiData.TaskRunning = true;
                SetProgress(0);
                StartTaskButton.Content = QueryLangDict("Button_StartTask_Stop");
                taskFiles = new TaskFiles(FilesList.Items);
                await Task.Run(StartTask);

                StartTaskButton.Content = QueryLangDict("Button_StartTask_Finished");
                SetProgress(1);
                await Task.Delay(3000);

                UiData.TaskRunning = false;
                SetProgress();
                StartTaskButton.Content = QueryLangDict("Button_StartTask_Start");
            }
        }