static void Main(string[] args) { Console.WriteLine("Starting Nuclear Watchdog"); HeartbeatClient client = new HeartbeatClient(); HeartbeatSender heartbeatSender = new HeartbeatSender(client); try { heartbeatSender.Register(); } catch (System.ServiceModel.EndpointNotFoundException) { Console.WriteLine("Failed to connect to the heartbeat receiver service."); Console.WriteLine("Are you sure the service is running?"); Environment.Exit(1); } ReactorClient reactor = new ReactorClient(); ReactorMonitor reactorMonitor = new ReactorMonitor(heartbeatSender, reactor, 350); Thread reactorMonitorThread = new Thread(new ThreadStart(reactorMonitor.Monitor)); reactorMonitorThread.Start(); Thread heartbeatThread = new Thread(new ThreadStart(heartbeatSender.Beat)); heartbeatThread.Start(); // Run for 60 seconds Thread.Sleep(60000); reactorMonitorThread.Abort(); reactorMonitorThread.Join(); heartbeatThread.Abort(); heartbeatThread.Join(); heartbeatSender.Unregister(); Console.WriteLine("Stopping Nuclear Watchdog"); }
public ReactorMonitor(HeartbeatSender heartbeatSender, ReactorClient reactor, double threshold) { this.random = new Random(); this.heartbeatSender = heartbeatSender; this.reactor = reactor; this.threshold = threshold; }