Ejemplo n.º 1
0
 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());
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 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.
         }
     }
 }