我需要在C#
中等待过程直到开始赞:Autoit中的ProcessWait("notepad.exe")
https://www.autoitscript.com/autoit3/docs/functions/ProcessWait.htm
答案 0 :(得分:2)
此处有更多信息:Process Information and Notifications using 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");
}
}
}