private void ButtonStop_Click(object sender, System.EventArgs e)
{
  System.Diagnostics.Process[] myProcesses;
  myProcesses =
    System.Diagnostics.Process.GetProcessesByName("Notepad");
  foreach (System.Diagnostics.Process instance in myProcesses)
  {
    instance.CloseMainWindow();
    instance.Close();
  }
}
 
// Настройка ожидания завершения выполнения процесса Блокнота
private void ButtonStop_Click(object sender, System.EventArgs e)
{
  System.Diagnostics.Process[] myProcesses;
  myProcesses =
    System.Diagnostics.Process.GetProcessesByName("Notepad");
  foreach (System.Diagnostics.Process instance in myProcesses)
  {
    instance.CloseMainWindow();
    instance.WaitForExit(3000);
    instance.Close();
  }
}

Добавить комментарий