Example #1
0
        private void Run()
        {
            while (_running)
            {
                if (_currentProcess == null)
                {
                    Process[] processes = Process.GetProcessesByName(_processName);
                    if (processes.Length > 0)
                    {
                        _currentProcess = processes[0];
                        ProcessStarted?.Invoke(this, new ProcessEventArgs
                        {
                            Process = _currentProcess
                        });
                    }
                }

                if (_currentProcess != null)
                {
                    if (_currentProcess.HasExited)
                    {
                        ProcessStopped?.Invoke(this, new ProcessEventArgs
                        {
                            Process = _currentProcess
                        });
                        _currentProcess = null;
                    }
                }

                Thread.Sleep(500);
            }
        }
        /// <summary>
        /// Raise process stopped event
        /// </summary>
        protected void RaiseProcessStopped()
        {
            isRunning = false;

            ProcessStopped?.Invoke(this, EventArgs.Empty);

            LogProvider.Log.Info(this, $"\"{SiteString}\" importer has been stopped");
        }
Example #3
0
        /// <summary>
        /// Raise process stopped event
        /// </summary>
        protected void RaiseProcessStopped()
        {
            isRunning = false;

            ProcessStopped?.Invoke(this, EventArgs.Empty);

            LogProvider.Log.Info(this, $"\"{Identifier}\" catcher has been stopped");
        }
Example #4
0
 private void FinishedProcess(object sender, EventArgs ea)
 {
     if (DateTime.Now - StartTime < TimeSpan.FromMilliseconds(3000))
     {
         Process.Start();
     }
     else
     {
         (sender as Process).Exited -= FinishedProcess;
         ProcessStopped?.Invoke();
     }
 }
        private void Tick(object sender, ElapsedEventArgs e)
        {
            var oldCache = this.ProcessCache;

            this.UpdateProcessCache();
            var(deleted, added) = oldCache.GetFullDifferenceTo(this.ProcessCache);

            foreach (var add in added)
            {
                ProcessStarted?.Invoke(this, new ProcessEventArgs(add.Value));
            }
            foreach (var del in deleted)
            {
                ProcessStopped?.Invoke(this, new ProcessEventArgs(del.Value));
            }
        }
Example #6
0
        private void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
            Process[] newProcesses = Process.GetProcesses();
            foreach (Process startedProcess in newProcesses.Except(_lastScannedProcesses, _comparer))
            {
                ProcessStarted?.Invoke(this, new ProcessEventArgs(startedProcess));
                _logger.Verbose("Started Process: {startedProcess}", startedProcess.ProcessName);
            }

            foreach (Process stoppedProcess in _lastScannedProcesses.Except(newProcesses, _comparer))
            {
                ProcessStopped?.Invoke(this, new ProcessEventArgs(stoppedProcess));
                _logger.Verbose("Stopped Process: {stoppedProcess}", stoppedProcess.ProcessName);
            }

            _lastScannedProcesses = newProcesses;
        }
Example #7
0
 /**
  * Create file in control dir, disable filters and wait for process to end
  */
 public void StopProcess()
 {
     StoppingProcess?.Invoke();
     Process[] allProcesses = Process.GetProcesses();
     Process[] processes    = Process.GetProcessesByName(Configuration.GetSetting(Configuration.PROCESS_NAME));
     foreach (Process p in processes)
     {
         if (!File.Exists(Configuration.GetSetting(Configuration.STOP_FILE_PATH)))
         {
             var stopFile = File.Create(Configuration.GetSetting(Configuration.STOP_FILE_PATH));
             stopFile.Close();
         }
         p.WaitForExit();
     }
     _processRunning = false;
     ProcessStopped?.Invoke();
 }
Example #8
0
 private void onComplete(object o, RunWorkerCompletedEventArgs args)
 {
     _memoryWorker = null;
     ProcessStopped?.Invoke(this, EventArgs.Empty);
 }
Example #9
0
        /// Raise process stopped event
        /// </summary>
        private void RaiseProcessStopped()
        {
            isRunning = false;

            ProcessStopped?.Invoke(this, EventArgs.Empty);
        }
Example #10
0
 private void WatchedProcessStopped(object sender, EventArgs e)
 {
     _watchedProcess = null;
     ProcessStopped?.Invoke(this, new EventArgs());
 }
Example #11
0
 private void OnProcessStopped(object sender, EventArrivedEventArgs e)
 {
     Console.WriteLine("----- Process Stopped -----");
     ProcessStopped?.Invoke(this, new ProcessStoppedEventArgs(e));
 }
Example #12
0
 protected virtual void RaiseProcessStoppedEvent()
 {
     ProcessStopped?.Invoke(this, EventArgs.Empty);
 }