C#检测进程退出
发布时间:2020-12-15 20:03:27 所属栏目:百科 来源:网络整理
导读:我有以下代码: private void fileSystemWatcher_Changed(object sender,System.IO.FileSystemEventArgs e) { System.Diagnostics.Process execute = new System.Diagnostics.Process(); execute.StartInfo.FileName = e.FullPath; execute.Start(); //Proce
我有以下代码:
private void fileSystemWatcher_Changed(object sender,System.IO.FileSystemEventArgs e) { System.Diagnostics.Process execute = new System.Diagnostics.Process(); execute.StartInfo.FileName = e.FullPath; execute.Start(); //Process now started,detect exit here } FileSystemWatcher正在观看保存.exe文件的文件夹.保存到该文件夹??的文件正确执行.但是当打开的exe关闭时,应该触发另一个函数. 有一个简单的方法吗? 解决方法
Process.WaitForExit.
顺便说一下,由于Process实现了IDisposable,你真的想要: using (System.Diagnostics.Process execute = new System.Diagnostics.Process()) { execute.StartInfo.FileName = e.FullPath; execute.Start(); //Process now started,detect exit here } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |