comparison ServerMonitor/Objects/ServerMonitor.cs @ 28:437442cd8090

Fix checks still running after a server is deleted and checks not running immediately after a server is created.
author Brad Greco <brad@bgreco.net>
date Sun, 02 Jun 2019 17:55:38 -0400
parents 781d8b980be1
children f6235dc0a8ec
comparison
equal deleted inserted replaced
27:e59ec1585616 28:437442cd8090
65 /// <param name="server">The server to be added.</param> 65 /// <param name="server">The server to be added.</param>
66 public void AddServer(Server server) 66 public void AddServer(Server server)
67 { 67 {
68 Servers.Add(server); 68 Servers.Add(server);
69 SaveServers(); 69 SaveServers();
70 server.CheckModified += Server_CheckModified;
71 server.EnabledChanged += Server_EnabledChanged;
70 } 72 }
71 73
72 /// <summary>Deletes a server from the server monitor.</summary> 74 /// <summary>Deletes a server from the server monitor.</summary>
73 /// <param name="server">The server to be deleted.</param> 75 /// <param name="server">The server to be deleted.</param>
74 public void DeleteServer(Server server) 76 public void DeleteServer(Server server)
75 { 77 {
76 Servers.Remove(server); 78 Servers.Remove(server);
79 // Cancel all queued and executing checks belonging to a
80 // server that was deleted.
81 foreach (Check check in server.Checks)
82 {
83 CancelCheck(check);
84 }
77 SaveServers(); 85 SaveServers();
78 } 86 }
79 87
80 /// <summary>Loads all servers and checks from the config file.</summary> 88 /// <summary>Loads all servers and checks from the config file.</summary>
81 public void LoadServers() 89 public void LoadServers()