在某些时候,我需要抓住{
"feed": {
"data": [
{
"from": {
"name": "John's Tires",
"id": "114615108955555"
},
{
"from": {
"name": "John Smith",
"id": "123615108951010"
},
流程启动及其完成的事件。我的代码正在使用通常的用户权限。具有系统权限的Windows将启动msiexec
进程,因此我无法执行msiexec
并检查该进程的Refresh()
属性。
HasExited
但即使在while (true) {
Process[] msi = Process
.GetProcessesByName("msiexec");
if (msi.Length > 0) break;
}
// The `msiexec` is launched. Now to wait its finishing...
while (true) {
Process[] msi = Process
.GetProcessesByName("msiexec");
if (msi.Length == 0) break; // Here is `false` always!
}
// Components was installed.
完成后,第二个while
循环也会始终显示msi.Length == 1
。为什么会这样?我该如何解决?
答案 0 :(得分:0)
请注意,可以同时运行多个具有相同名称的进程。因此,msi.Length
可以是> 1.它也可以是>在启动msiexec之前为0。
找到msiexec进程后,您可以测试进程的GetProcessesByName
属性,而不是再次调用HasExited
。
如果msi.Length
是> 1,然后等待,直到非退出进程的数量减少1。