/// <summary> /// To find each process. /// </summary> protected virtual void findProcess() { bool isAdded = false; foreach (var p in Process.GetProcessesByName(ProcessName)) { if (teamViewers.ContainsKey(p.Id)) { updateProcess(teamViewers[p.Id], p); continue; } ITeamViewer tv = new TeamViewer(p); BeforeAdd(this, new TeamViewerEventArgs(tv)); teamViewers[p.Id] = tv; isAdded = true; log.info($"Found process: {p.Id} : {tv.CommandLine}"); } if (isAdded) { Updated(this, new EventArgs()); } }
/// <summary> /// To find all processes. /// </summary> public void findAll() { teamViewers.Clear(); foreach (var p in Process.GetProcessesByName(ProcessName)) { ITeamViewer tv = new TeamViewer(p); BeforeAdd(this, new TeamViewerEventArgs(tv)); teamViewers[p.Id] = tv; } Updated(this, new EventArgs()); }