private void updateStatus() { var status = handler.GetStatus(); if (status != null) { connected = true; networkId.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { this.networkId.Text = status.Address; })); versionString.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { this.versionString.Content = status.Version; })); onlineStatus.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { this.onlineStatus.Content = (status.Online ? "ONLINE" : "OFFLINE"); })); } else { connected = false; networkId.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { this.networkId.Text = ""; })); versionString.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { this.versionString.Content = "0"; })); onlineStatus.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { this.onlineStatus.Content = "OFFLINE"; })); } }
private void run() { try { while (runThread.IsAlive) { APIHandler handler = APIHandler.Instance; if (handler != null) { handler.GetNetworks(apiNetworkCallback); handler.GetStatus(apiStatusCallback); } Thread.Sleep(2000); } } catch { Console.WriteLine("Monitor Thread Ended"); } }