等待进程,直到启动 c#
本文关键字:启动 进程 等待 | 更新日期: 2023-09-27 18:35:56
>我需要等待进程直到 c# 中启动
喜欢 : ProcessWait("notepad.exe")
在自动
https://www.autoitscript.com/autoit3/docs/functions/ProcessWait.htm
详细信息:使用 WMI 处理信息和通知
using System;
using System.Diagnostics;
using System.Management;
namespace Test
{
public static class Program
{
static void Main(string[] args)
{
var queryString =
"SELECT TargetInstance " +
"FROM __InstanceCreationEvent WITHIN 1 " +
"WHERE TargetInstance ISA 'Win32_Process' " +
"AND TargetInstance.Name LIKE 'notepad.exe'";
var scope = @"''.'root'CIMV2";
var watcher = new ManagementEventWatcher(scope, queryString);
watcher.EventArrived += watcher_EventArrived;
watcher.Start();
Process.Start("notepad.exe");
Console.ReadKey();
}
static void watcher_EventArrived(object sender, EventArrivedEventArgs e)
{
Console.WriteLine("Notepad has been started");
}
}
}