C# 실행하고 싶은 프로그램이 닫혔는지 감지하고 싶습니다. 나는 현재시작한 프로세스가 닫혔는지 감지합니다.
Process.Start(Environment.CurrentDirectory + @"\Card Downloader.exe");
사람이 아마도 다른 발사기를 사용하여이 작업을 수행하는 방법을 가지고있는 명령을 실행입니까?
C# 실행하고 싶은 프로그램이 닫혔는지 감지하고 싶습니다. 나는 현재시작한 프로세스가 닫혔는지 감지합니다.
Process.Start(Environment.CurrentDirectory + @"\Card Downloader.exe");
사람이 아마도 다른 발사기를 사용하여이 작업을 수행하는 방법을 가지고있는 명령을 실행입니까?
Process.Start() 메서드는 Process 개체를 반환합니다. 변수에 할당하고 WaitForExit()을 호출하십시오.
Process.Start
메서드는 Process 인스턴스를 반환합니다. 이 인스턴스에서는 WaitForExit
과 같은 사용 가능한 방법 중 일부를 사용하거나이 프로세스가 끝날 때 트리거되는 Exited
이벤트에 가입 할 수 있습니다.
var process = Process.Start(Environment.CurrentDirectory + @"\Card Downloader.exe");
process.Exited += (sender, e) =>
{
// this will be called when the process exists
};
사용할 수 Process.Exit
이벤트
var myProcess = new Process();
...
myProcess.Exited += new EventHandler(myProcess_Exited);
myProcess.Start();