示例#1
0
        private PrcessStatus CheckPrcessStatus(CheckProcess checkProcess)
        {
            var processInfoResult = new PrcessStatus();
            var proc = Process.GetProcesses().FirstOrDefault(x => string.Compare(checkProcess.Name, x.ProcessName, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase) == 0);

            processInfoResult.Name = checkProcess.Name;

            if ((!_watchDogFlags.ContainsKey(checkProcess.Name) || _watchDogFlags[checkProcess.Name] == false) && proc != null)
            {
                _logger.Warn($"processController {checkProcess.Name} without WD, need restart app");
            }

            processInfoResult.StatusProcess =
                proc != null ? PrcessStatus.ProcStatus.Running : PrcessStatus.ProcStatus.NotRunning;
            return(processInfoResult);
        }
        public void Handle(PrcessStatus procesStatus)
        {
            var requiredProcName = _config.DependencyProcess.Name;

            if (!procesStatus.PrcessName(requiredProcName))
            {
                return;
            }

            if (procesStatus.Status == MessageStatus.Info && !procesStatus.Ready)
            {
                _lockEvent.Reset(); //pause
            }
            if (procesStatus.Status == MessageStatus.Info && procesStatus.Ready)
            {
                _lockEvent.Set(); //restore
            }
        }