Example #1
0
 // is called when the program stops again
 protected virtual void OnProgramShutdown(ProcessObject game)
 {
     ProgramShutdown?.Invoke(this, new ProcessEventArgs()
     {
         processName = game.Name
     });
 }
Example #2
0
 // is called when the program is starting up
 protected virtual void OnProgramRunning(ProcessObject game)
 {
     if (ProgramRunning != null)
     {
         ProgramRunning(this, new ProcessEventArgs()
         {
             processName = game.Name
         });
     }
 }
Example #3
0
 // allow only one program to send OnProgramRunning at a time with _allreadyRunning bool
 public void CheckProgramRunning(ProcessObject game)
 {
     // Program starting
     if (!_allreadyRunning && !game.IsRunning && IsProgramRunning(game.Name))
     {
         game.IsRunning   = true;
         _allreadyRunning = true;
         Console.WriteLine(game.ToString());
         OnProgramRunning(game);
     }
     // Program shutting down
     // when the program that started up first shuts down, we change _allreadyRunning to false
     // so another program can be our priority
     else if (game.IsRunning && !IsProgramRunning(game.Name))
     {
         game.IsRunning   = false;
         _allreadyRunning = false;
         OnProgramShutdown(game);
     }
 }