public static IEnumerable <IPCClient> QueryAll() { var thisProcess = Process.GetCurrentProcess(); foreach (var process in Process.GetProcessesByName(thisProcess.ProcessName)) { if (process.Id == thisProcess.Id) { continue; } IPCClient processChannel = null; try { processChannel = new IPCClient(process); } catch { // ignored } if (processChannel != null) { yield return(processChannel); } } }
public static IPCClient QueryByStatus(InstanceStatus status) { var thisProcess = Process.GetCurrentProcess(); foreach (var process in Process.GetProcessesByName(thisProcess.ProcessName)) { if (process.Id != thisProcess.Id) { try { var processChannel = new IPCClient(process); if (processChannel.Status == status) { return(processChannel); } } catch { // ignored } } } return(null); }