private void BtnClientConfig_Click(object sender, EventArgs e) { using (var dlg = new ClientConfigDlg()) { dlg.Settings = Settings; if (dlg.ShowDialog() != DialogResult.OK) { return; } Settings = dlg.Settings; SaveConfig(Settings); _ = StatusTimer.StartSingle(Settings.StatusRequestInterval); } }
private void StatusTimerCallback(object param) { try { var status = WcfProxy.GetCurrentStatus(); this.InvokeIfRequired(() => { if (logToken != status.LogToken) { // Has to be in this order // Otherwise clearing the DGV causes cell value requests // in this thread before continuing here. // Which has a high chance of adding items in the // LogEntries list, which are subsequently cleared, // leaving empty cells in the DGV that won't be filled. DgvLog.RowCount = 0; LogEntries.Clear(); } logToken = status.LogToken; // If we are scrolled down, we auto scroll var prevRowCount = DgvLog.RowCount; DgvLog.RowCount = status.LogCount; if (DgvLog.GetLastDisplayedScrollingRowIndex(false) + 1 >= prevRowCount) { DgvLog.FirstDisplayedScrollingRowIndex = DgvLog.RowCount - 1; } UpdateOperation(status.Operation); DuplicateCount = status.DuplicateCount; LblDuplicateCount.Text = string.Format( StatusInfoDuplicateCount, DuplicateCount); BtnResolveDuplicates.Enabled = DuplicateCount > 0; BtnDiscardDuplicates.Enabled = DuplicateCount > 0; }); } catch (Exception ex) when( ex is EndpointNotFoundException || ex is CommunicationException || ex is TimeoutException) { Debug.Print("Status request failed with: " + ex.Message); this.InvokeIfRequired(() => { BtnResolveDuplicates.Enabled = false; UpdateOperation(new OperationInfo { Message = "Connecting...", ProgressStyle = ProgressStyle.Marquee, }); }); } finally { _ = StatusTimer.StartSingle(Settings.StatusRequestInterval); } }