Core - Further reduced allocations in process monitor checking

This commit is contained in:
Diogo Trindade committed 2023-09-04 15:55:27 +01:00
1 parent d26f62223b
commit 8a1b302e48
2 files changed
+35 -10

No files matched your search

@@ -38,16 +38,7 @@ public class ProcessActivationRequirement : IModuleActivationRequirement
/// <inheritdoc />
public bool Evaluate()
{
if (!ProcessMonitor.IsStarted || (ProcessName == null && Location == null))
return false;
IEnumerable<ProcessInfo> processes = ProcessMonitor.Processes;
if (ProcessName != null)
processes = processes.Where(p => string.Equals(p.ProcessName, ProcessName, StringComparison.InvariantCultureIgnoreCase));
if (Location != null)
processes = processes.Where(p => string.Equals(Path.GetDirectoryName(p.Executable), Location, StringComparison.InvariantCultureIgnoreCase));
return processes.Any();
return ProcessMonitor.IsProcessRunning(ProcessName, Location);
}
/// <inheritdoc />