C#进程退出事件

C#进程退出事件,c#,.net,wpf,C#,.net,Wpf,我正在创建一个负责运行某个程序的进程,我在程序终止时添加了一个事件,但是当我关闭程序时,事件不会启动 这是我的代码,前面的创建过程我的程序解压缩.exe文件并运行 使用事件创建新流程: Process installerProcess = new Process(); installerProcess.StartInfo.FileName = unpackPath + @"\" + unpackFileName; installerProcess.Exited += Inst

我正在创建一个负责运行某个程序的进程,我在程序终止时添加了一个事件,但是当我关闭程序时,事件不会启动

这是我的代码,前面的创建过程我的程序解压缩.exe文件并运行

使用事件创建新流程:

Process installerProcess = new Process();
installerProcess.StartInfo.FileName = unpackPath + @"\" + unpackFileName;
installerProcess.Exited += InstallerProcess_Exited;
installerProcess.Start();
活动:

private void InstallerProcess_Exited(object sender, EventArgs e)
{
   Debug.WriteLine("Process end");
}

您必须在
进程
对象上将
EnableRaisingEvents
设置为true:

Process installerProcess = new Process();
installerProcess.StartInfo.FileName = unpackPath + @"\" + unpackFileName;
installerProcess.EnableRaisingEvents = true;
installerProcess.Exited += InstallerProcess_Exited;
installerProcess.Start();

您必须在
进程
对象上将
EnableRaisingEvents
设置为true:

Process installerProcess = new Process();
installerProcess.StartInfo.FileName = unpackPath + @"\" + unpackFileName;
installerProcess.EnableRaisingEvents = true;
installerProcess.Exited += InstallerProcess_Exited;
installerProcess.Start();

您可能必须添加
-o
选项来覆盖现有文件而不进行提示,否则解压可能正在等待答案。您可能必须添加
-o
选项来覆盖现有文件而不进行提示,否则解压可能正在等待答案。Ty需要帮助,工作正常。Ty需要帮助,工作正常。