static void Run() { while (true) { lock (calls) { for (int i = 0; i < calls.Count; i++) { calls[i] -= 0.1f; } } calls.RemoveAll(HasExpired); if (calls.Count > 0) { callsPerSec = calls.Last(); } else { callsPerSec = 0; } PoloniexBot.GUI.GUIManager.UpdateApiCalls(callsPerSec); ThreadManager.ReportAlive("APICallTracker"); Thread.Sleep(1000); } }
static void Run() { while (true) { try { Ping ping = new Ping(); PingReply reply = ping.Send("8.8.8.8"); if (reply.Status == IPStatus.Success) { lastReplyTime = reply.RoundtripTime; PoloniexBot.GUI.GUIManager.UpdatePing(lastReplyTime); missCount = 0; if (netDown) { PoloniexBot.GUI.GUIManager.SetNetworkStateMessage(PoloniexBot.GUI.MainSummaryGraph.NetworkMessageState.Restored); netDown = false; new Task(() => { Utility.Log.Manager.LogBasicMessage("REBOOT"); ClientManager.Reboot(); }).Start(); ErrorLog.ReportLog("Network Restored"); } } else if (!netDown) { missCount++; PoloniexBot.GUI.GUIManager.UpdatePing(0); if (missCount > 3) { netDown = true; PoloniexBot.GUI.GUIManager.SetNetworkStateMessage(PoloniexBot.GUI.MainSummaryGraph.NetworkMessageState.Down); ErrorLog.ReportError("Network Down"); } } } catch (PingException) { missCount++; PoloniexBot.GUI.GUIManager.UpdatePing(0); if (missCount > 3) { if (!netDown) { netDown = true; PoloniexBot.GUI.GUIManager.SetNetworkStateMessage(PoloniexBot.GUI.MainSummaryGraph.NetworkMessageState.Down); ErrorLog.ReportError("Network Down"); } } } ThreadManager.ReportAlive("NetworkStatus"); Thread.Sleep(1000); } }