コード例 #1
0
ファイル: Zombification.cs プロジェクト: dlebansais/ZombifyMe
        /// <summary>
        /// Ensures the monitoring process is restarted if it crashed.
        /// </summary>
        /// <param name="monitoring">The monitoring information.</param>
        /// <param name="monitorProcess">The monitoring process.</param>
        /// <param name="cancelEvent">The cancellation event.</param>
        private static void ExecuteSymmetricWatch(Monitoring monitoring, Process monitorProcess, EventWaitHandle cancelEvent)
        {
            TimeSpan AliveTimeout = monitoring.AliveTimeout;

            Debug.Assert(AliveTimeout > TimeSpan.Zero);

            bool IsAlive = true;

            AliveWatch.Start();

            while (IsAlive)
            {
                if (AliveWatch.Elapsed >= AliveTimeout)
                {
                    break;
                }

                if (cancelEvent.WaitOne(SharedDefinitions.CheckInterval))
                {
                    break;
                }

                IsAlive = !monitorProcess.HasExited;

                if (!IsAlive)
                {
                    using (monitorProcess)
                    {
                    }

                    // Wait the same delay as if restarting the original process.
                    Thread.Sleep(monitoring.Delay);

                    ZombifyMeInternal(monitoring, out _);
                }
            }
        }
コード例 #2
0
ファイル: Zombification.cs プロジェクト: dlebansais/ZombifyMe
 /// <summary>
 /// Tells the monitoring thread the main thread is alive.
 /// </summary>
 public static void SetAlive()
 {
     AliveWatch.Restart();
 }