void updateOutput() { try { if (!loadCompleted || SelectedProcessor == null) { Output = null; return; } var selectedItems = StreamedItemsView.Cast <TextItemViewModel>().Where(si => si.IsSelected).Select(si => si.Text).ToArray(); // do the work in a task to prevent the UI from freezing Task.Factory.StartNew(() => { string outputText = outputService.GetOutput(selectedItems, SelectedProcessor); Invoke(() => Output = outputText); }); } catch (Exception ex) { Output = null; var procName = SelectedProcessor == null ? "[No Processor Selected]" : SelectedProcessor.Name; logService.Write("Failed to build the output with processor '{0}': {1}", procName, ex.Message); } }
private void BtnSearch_Click(object sender, EventArgs e) { string month = dtpDate.Value.ToString("yyyyMM"); string lmonth = dtpDate.Value.AddMonths(-1).ToString("yyyyMM"); outList = service.GetOutput(month, lmonth); dgvMainGrid.DataSource = outList; }