public void BlockApplications(object sender, ProcessWatcher.ProcessEventArgs e) { foreach (string item in blockedApplications) //For every item in the list of blocked applications... { if (blockType == BlockType.Blacklist) { foreach (Process p in e.RelatedProcesses) { if (p.MainWindowTitle.Contains(item)) //If the process related to the event matches a blocked application... { p.Kill(); //Kill the process associated with the event. blockedApplication = item; ApplicationBlocked?.Invoke(this, new EventArgs()); } } } else { foreach (Process p in e.RelatedProcesses) { if (p.MainWindowTitle.Contains(item)) //If the process related to the event does not match a whitelisted application... { p.Kill(); //Kill the process associated with the event. blockedApplication = item; ApplicationBlocked?.Invoke(this, new EventArgs()); } } } } }
public void BlockApplications(object sender, ProcessWatcher.ProcessEventArgs e) { foreach (string item in blockedApplications) //For every item in the list of blocked applications... { if (e.RelatedProcess.MainWindowTitle.Contains(item)) //If the process relatesd to the event matches a blocked application... { e.RelatedProcess.Kill(); //Kill the process associated with the event. } } }