How can I make an indicator of resource availability? Ie, there is a resource that needs to be checked whether it is available or not; constantly pinging is not an option at the moment:
label.Content = new Ping().Send("172.30.216.27").RoundtripTime.ToString() + "ms"; There is an idea to make a green access indicator red no, poll every 20 seconds. But I do not know how to do this, please help.
UPD People help stop this flow
new Thread(() => { var ipAddr = _label.Text; if (!string.IsNullOrEmpty(ipAddr)) { ls1: try { var pingSender = new Ping(); var reply = pingSender.Send(ipAddr); if (reply != null && reply.Status == IPStatus.Success) { Invoke((Action) (() => { _label.BackColor = Color.Green; })); } else { Invoke((Action) (() => { _label.BackColor = Color.Red; })); } } catch { this.Invoke((Action) (() => { _label.BackColor = Color.Red; })); } Thread.Sleep(20000); goto ls1; } }).Start();