diff ServerMonitor/Objects/Checks/Check.cs @ 4:3142e52cbe69

Lots more progress
author Brad Greco <brad@bgreco.net>
date Sun, 10 Feb 2019 20:51:26 -0500
parents 453ecc1ed9ea
children 052aa62cb42a
line wrap: on
line diff
--- a/ServerMonitor/Objects/Checks/Check.cs	Fri Jan 11 22:34:18 2019 -0500
+++ b/ServerMonitor/Objects/Checks/Check.cs	Sun Feb 10 20:51:26 2019 -0500
@@ -59,6 +59,8 @@
 
         public CheckStatus Status { get; set; }
 
+        public CheckStatus LastRunStatus { get; set; }
+
         public CheckStatus FailStatus { get; set; }
 
         [XmlIgnore]
@@ -90,7 +92,9 @@
 
         public async Task<CheckResult> ExecuteAsync(CancellationToken token = default(CancellationToken), bool update = true)
         {
-            //TODO check cancellation token before proceeding
+            if (token.IsCancellationRequested)
+                return null;
+
             CheckResult result;
             DateTime startTime = DateTime.Now;
             try
@@ -122,6 +126,7 @@
             if (update)
             {
                 Status = result.CheckStatus;
+                LastRunStatus = result.CheckStatus;
                 LastMessage = result.Message;
                 LastRunTime = result.EndTime;
             }
@@ -222,7 +227,7 @@
             {
                 if (result == null)
                     continue;
-                if (result.CheckStatus != CheckStatus.Success)
+                if (result.Failed)
                     failed = true;
                 message.AppendLine(result.Message);
             }