private void timer_Tick(object sender, EventArgs e) { lock (lstTrackerInfo.Items) { bool tracking = _chat.IsTrackerRunning; foreach (ListViewItem item in lstTrackerInfo.Items) { if (tracking) { TrackerClient tracker = item.Tag as TrackerClient; TimeSpan updateIn; Exception lastException; int peerCount; if (tracker == null) { updateIn = _chat.DhtNextUpdateIn(); lastException = _chat.DhtLastException(); peerCount = _chat.DhtGetTotalPeers(); } else { updateIn = tracker.NextUpdateIn(); lastException = tracker.LastException; peerCount = tracker.Peers.Count; } string strUpdateIn = "updating..."; if (updateIn.TotalSeconds > 1) { strUpdateIn = ""; if (updateIn.Hours > 0) { strUpdateIn = updateIn.Hours + "h "; } if (updateIn.Minutes > 0) { strUpdateIn += updateIn.Minutes + "m "; } strUpdateIn += updateIn.Seconds + "s"; } item.SubItems[1].Text = lastException == null ? "working" : "[" + tracker.RetriesDone + "] " + lastException.Message; item.SubItems[2].Text = strUpdateIn; item.SubItems[3].Text = peerCount.ToString(); } else { item.SubItems[1].Text = "not tracking"; item.SubItems[2].Text = ""; item.SubItems[3].Text = ""; } } } }