27 namespace Ntp.Common.App
34 this.interval = interval;
49 var thread =
new Thread(Pulse)
53 Priority = ThreadPriority.AboveNormal
57 log.HeartbeatStarted(interval);
69 int next = (beats + 1)*interval;
70 var sleep = start.AddMinutes(next).Subtract(DateTime.Now).TotalMilliseconds;
71 Thread.Sleep(Convert.ToInt32(sleep));
74 var span = TimeSpan.FromMinutes(beats*interval);
75 var builder =
new StringBuilder();
79 builder.Append(span.Days);
80 builder.Append(
" day");
90 if (span.Hours != 0 && span.Minutes == 0)
92 builder.Append(
" and ");
94 else if (span.Hours == 0 && span.Minutes != 0)
96 builder.Append(
" and ");
98 else if (span.Hours != 0 && span.Minutes != 0)
100 builder.Append(
", ");
106 builder.Append(span.Hours);
107 builder.Append(
" hour");
115 if (span.Hours >= 1 && span.Minutes != 0)
120 if (span.Hours != 0 && span.Minutes != 0)
122 builder.Append(
"and ");
125 if (span.Minutes != 0)
127 builder.Append(span.Minutes);
128 builder.Append(
" minute");
131 if (span.Minutes > 1)
136 log.HeartbeatUptime(builder.ToString());
Heartbeat(LogBase log, int interval)