public void SetStartupSequenceToComplete() { StartupSequenceIsComplete = true; LastHeartbeat.Restart(); OnStartupSequenceIsComplete?.Invoke(this, new ProfileEventArgs(Profile)); }
public void Stop() { // try to aquire lock, if fail then kill process anyways. bool lockAquried = Monitor.TryEnter(_lockObject, 500); if (IsRunning) { if (BotProcess != null) { if (!BotProcess.HasExitedSafe()) { CloseBotProcess(); } else { BotProcess = null; } } LastHeartbeat.Reset(); IsRunning = false; StartupSequenceIsComplete = false; } if (lockAquried) // release lock if it was aquired { Monitor.Exit(_lockObject); } }
/// <summary> /// Returns whether or not the service is suspected to have /// crashed. This is based on whether 2 cycle times have passed /// since the last run or 2 heartbeat cycle times have passed /// since the last heartbeat. /// </summary> /// <returns></returns> public bool IsCrashSuspected() { return (Math.Abs(LastRunTime.Subtract(_serverTime).TotalMinutes) > RunIntervalMinutes * 2 || // More than 2 cycles times have passed since last run time Math.Abs(LastHeartbeat.Subtract(_serverTime).TotalMinutes) > EngineBase.HEARTBEAT_INTERVAL.TotalMinutes * 2); // More than 2 heartbeat cycle times have passed since last heartbeat }
public void SetStartupSequenceToComplete() { StartupSequenceIsComplete = true; LastHeartbeat.Restart(); if (HbRelogManager.Settings.MinimizeHbOnStart) { NativeMethods.ShowWindow(BotProcess.MainWindowHandle, NativeMethods.ShowWindowCommands.Minimize); } if (OnStartupSequenceIsComplete != null) { OnStartupSequenceIsComplete(this, new ProfileEventArgs(Profile)); } }
public bool IsAlive(TimeSpan ttl) { return(LastHeartbeat.Add(ttl) > DateTime.Now); }