/// <summary> /// Exiting event to Reset HealthCheckTimer and managing which /// </summary> /// <param name="healthCheckName">The name of the Health Check</param> /// <param name="timer">a<see cref="HealthCheckTimer"/> object</param> private void ExitTask(string healthCheckName, HealthCheckTimer timer) { lock (this) { runningHealthChecks.Remove(healthCheckName); //don't recalculate next run time if stopping flag has been if (!stoppingEvent.WaitOne(0)) { timer.Reset(); Log.DebugFormat($"timer for {healthCheckName} with {timer.Interval}ms interval (next run:{timer.NextRunTime})"); } Monitor.PulseAll(this); } }
public HealthCheckList(IEnumerable <IHealthCheck> healthChecks, IKernel kernel) { this.kernel = kernel; runningHealthChecks = new List <string>(); //iterate through configurations and initialize the //HealthCheckTimer and add it ot the dictionary //that tracks timers and health check parameters foreach (var healthCheck in healthChecks) { HealthCheckTimer timer = new HealthCheckTimer(ScheduleProviderFactory.Build(healthCheck.ScheduleParams)); timer.Elapsed += timer_Elapsed; timer.AutoReset = false; Log.DebugFormat($"created timer for {healthCheck.Name}"); timers.Add(timer, healthCheck); } }
/// <summary> /// Stop a Health Check timer /// </summary> /// <param name="name">The name of the Health Check</param> /// <param name="timer">a <see cref="HealthCheckTimer"/> object</param> private static void StopHealthCheckTimer(string name, HealthCheckTimer timer) { timer.Stop(); Log.DebugFormat($"Stopping Health Check: {name}"); }
/// <summary> /// Initialize and start a health check timer /// </summary> /// <param name="name">The name of the Health Check</param> /// <param name="timer">a <see cref="HealthCheckTimer"/> object</param> private static void StartHealthCheckTimer(string name, HealthCheckTimer timer) { timer.Start(); Log.DebugFormat($"started timer for {name} with {timer.Interval} (next run:{timer.NextRunTime}) "); }