private async Task FilterExistingTraceRecords() { if (!this.IsControlsEnabled) { return; } this.Dispatcher.Invoke(() => { this._itemsSource.Clear(); }); ConnectionData connectionData = GetSelectedConnection(); ToggleControls(connectionData, false, Properties.OutputStrings.FilteringTraceFiles); IEnumerable <TraceRecord> list = Enumerable.Empty <TraceRecord>(); Dictionary <Guid, SystemUser> dictUsers = null; try { if (this._loadedRecords != null) { list = this._loadedRecords; } if (connectionData != null && _systemUserCache.ContainsKey(connectionData.ConnectionId)) { dictUsers = _systemUserCache[connectionData.ConnectionId]; } } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } string textName = string.Empty; Guid? requestId = null; Guid? activityId = null; int? threadNumber = null; FilterResults filterResults = FilterResults.SimilarActivityId; this.Dispatcher.Invoke(() => { textName = cmBFilter.Text; connectionData?.AddTraceFilter(textName); cmBFilter.Text = textName; { if (Guid.TryParse(txtBRequestId.Text, out var tempGuid) && tempGuid != Guid.Empty ) { requestId = tempGuid; } } { if (Guid.TryParse(txtBActivityId.Text, out var tempGuid) && tempGuid != Guid.Empty ) { activityId = tempGuid; } } if (int.TryParse(txtBThread.Text, out var tempInt)) { threadNumber = tempInt; } if (cmBFilterResults.SelectedIndex != -1) { filterResults = (FilterResults)cmBFilterResults.SelectedIndex; } }); list = await FilterTraceRecordsAsync(list, textName, filterResults, requestId, activityId, threadNumber); LoadTraceRecords(list, dictUsers); ToggleControls(connectionData, true, Properties.OutputStrings.FilteringTraceFilesCompletedFormat1, list.Count()); }