Exemplo n.º 1
0
 private static void ProcessWatcher_ProcessExited(ProcessManagerEvent obj)
 {
     try
     {
         if (obj.ProcessName.ToLower() == "wow.exe")
         {
             if (Processes.TryRemove(obj.ProcessId, out WowProcess pWowProcess))
             {
                 pWowProcess.Dispose();
                 log.Info($"{pWowProcess} Process closed, {Processes.Count} total");
                 OnWowProcessStopped();
                 WoWProcessStartedOrClosed?.Invoke();
                 WoWProcessClosed?.Invoke(obj.ProcessId);
             }
             else
             {
                 string name = obj.ProcessName.Substring(0, obj.ProcessName.Length - 4);
                 log.Error($"[{name}:{obj.ProcessId}] Closed WoW process not found");
             }
         }
     }
     catch (Exception ex)
     {
         log.Error($"[{obj.ProcessName}:{obj.ProcessId}] Process stopped with error: {ex.Message}");
     }
 }
Exemplo n.º 2
0
 private static void ProcessWatcher_ProcessStarted(ProcessManagerEvent obj)
 {
     try
     {
         string processName = obj.ProcessName.ToLower();
         if (processName == "wow.exe")
         {
             WowProcess wowProcess = new WowProcess(obj.ProcessId);
             Processes.TryAdd(obj.ProcessId, wowProcess);
             log.Info($"{wowProcess} Process started, {Processes.Count} total");
             WoWProcessStartedOrClosed?.Invoke();
             Task.Factory.StartNew(OnWowProcessStartup, wowProcess);
         }
     }
     catch (Exception ex)
     {
         log.Error($"[{obj.ProcessName}:{obj.ProcessId}] Process started with error: {ex.Message}");
     }
 }