bwehking
7 years agoOccasional Contributor
Let TryFind() return (a lot) faster for processes
Hi,
I try to determine in a loop whether certain processes are running and in turn handle different messageboxes that might appear. I noticed, that using
driver.TryFind<IProcess>(new ProcessPattern() { ProcessName = "notExistingProcess" }, 1, 0, out var process);
takes more than 3 seconds on my machine, whereas
Process.GetProcessesByName("notExistingProcess");
returns in a few (<10) milliseconds. I hoped that the timeOut parameter lets TryFind() return immediately, but obviously it's not the case.
Finding an existing process is fast:
driver.TryFind<IProcess>(new ProcessPattern() { ProcessName = "Explorer" }, 1, 0, out var process);
This takes 4 milliseconds.
Is there something I can do about it? Or do I have to use .NET Process class to check for the existing process first and only if it exists, use TestLeft to find the IProcess?
Thanks in advance!