private void timer_Tick(object sender, EventArgs e) { lock (lstPeerInfo.Items) { foreach (ListViewItem item in lstPeerInfo.Items) { int peerCount; bool enabled = false; switch (item.Text) { case "IPv4 DHT": peerCount = _network.DhtGetTotalIPv4Peers(); enabled = _network.IsIPv4DhtRunning; break; case "IPv6 DHT": peerCount = _network.DhtGetTotalIPv6Peers(); enabled = _network.IsIPv6DhtRunning; break; case "LAN DHT": peerCount = _network.DhtGetTotalLanPeers(); enabled = _network.IsLanDhtRunning; break; case "Tor DHT": peerCount = _network.DhtGetTotalTorPeers(); enabled = _network.IsTorDhtRunning; break; case "IPv4 Tcp Relay": peerCount = _network.TcpRelayGetTotalIPv4Peers(); enabled = _network.IsTcpRelayClientRunning; break; case "IPv6 Tcp Relay": peerCount = _network.TcpRelayGetTotalIPv6Peers(); enabled = _network.IsTcpRelayClientRunning; break; default: continue; } if (enabled) { if (item.Text.Contains("Tcp Relay")) { item.SubItems[1].Text = "working"; item.SubItems[2].Text = peerCount.ToString(); } else { string strUpdateIn; TimeSpan updateIn = _network.DhtNextUpdateIn(); if (updateIn.TotalSeconds > 2) { strUpdateIn = ""; if (updateIn.Hours > 0) { strUpdateIn = updateIn.Hours + "h "; } if (updateIn.Minutes > 0) { strUpdateIn += updateIn.Minutes + "m "; } strUpdateIn += updateIn.Seconds + "s"; } else { strUpdateIn = "updating..."; } item.SubItems[1].Text = strUpdateIn; item.SubItems[2].Text = peerCount.ToString(); } } else { item.SubItems[1].Text = "inactive"; item.SubItems[2].Text = ""; } } } }