private void InvalidateRowFilter() { if (_applyRowFilterTask != null) { _applyRowFilterTask.Dispose(); _applyRowFilterTask = null; } var bindingListView = GetBindingListView(); if (bindingListView == null) { return; } if (_filterText != tbxFind.Text) { var unfilteredRows = bindingListView.UnfilteredItems.ToArray(); if (string.IsNullOrEmpty(tbxFind.Text)) { bindingListView.SetFilteredItems(unfilteredRows); _filterText = ""; } else { _applyRowFilterTask = new ApplyRowFilterTask(unfilteredRows, bindingListView.GetItemProperties(new PropertyDescriptor[0]).Cast <PropertyDescriptor>().ToArray(), tbxFind.Text); new Action(_applyRowFilterTask.FilterBackground).BeginInvoke(ApplyRowFilterTaskCallback, _applyRowFilterTask); } } }
private void SetFilteredRowsNow(ApplyRowFilterTask applyRowFilterTask, IList <RowItem> rows) { try { } finally { applyRowFilterTask.Dispose(); } }
private void ApplyRowFilterTaskCallback(IAsyncResult result) { if (!result.IsCompleted) { return; } if (!ReferenceEquals(_applyRowFilterTask, result.AsyncState)) { return; } if (InvokeRequired) { BeginInvoke(new Action <IAsyncResult>(ApplyRowFilterTaskCallback), result); return; } if (!ReferenceEquals(_applyRowFilterTask, result.AsyncState)) { return; } try { var bindingListView = GetBindingListView(); if (bindingListView == null) { return; } bindingListView.SetFilteredItems(_applyRowFilterTask.FilteredRows.ToArray()); _filterText = _applyRowFilterTask.FilterText; } finally { _applyRowFilterTask.Dispose(); _applyRowFilterTask = null; } RefreshUi(); }