// Raised when each result's view model initializes private void resultViewModel_Initialized(object o, EventArgs args) { if (_updateResultsTimer == null) { // Use a throttler so refreshing the paged collection, which can be UI intensive, // doesn't happen too often _updateResultsTimer = new ThrottleTimer(500, () => { if (!_cancelled) { // Add the initialized results to the public-facing collection foreach (SearchResultViewModel viewModel in _checkedResults) { if (!_results.Contains(viewModel) && viewModel.IsInitialized) { _results.Add(viewModel); } } // Update the paged collection of results PagedResults.Refresh(); if (_numberWebResults == _NUMREQUESTS) // All requests have returned { IsSearching = false; // Reset busy state OnSearchCompleted(); // Raise completed event } } }); } _updateResultsTimer.Invoke(); }
private ThrottleTimer _layerOrderThrottler; // Throttles re-ordering of layers private void SelectedLayers_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { // Initialize the re-ordering throttler, if necessary if (_layerOrderThrottler == null) { _layerOrderThrottler = new ThrottleTimer(10, () => { orderSelectedLayers(); }); } // Invoke the throttler. When it executes, it will re-order the selected layers to match // their order in the available layers collectino _layerOrderThrottler.Invoke(); }
private ThrottleTimer _layerOrderThrottler; // Throttles re-ordering of layers private void SelectedLayers_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { // Initialize the re-ordering throttler, if necessary if (_layerOrderThrottler == null) _layerOrderThrottler = new ThrottleTimer(10, () => { orderSelectedLayers(); }); // Invoke the throttler. When it executes, it will re-order the selected layers to match // their order in the available layers collectino _layerOrderThrottler.Invoke(); }
// Raised when each result's view model initializes private void resultViewModel_Initialized(object o, EventArgs args) { if (_updateResultsTimer == null) { // Use a throttler so refreshing the paged collection, which can be UI intensive, // doesn't happen too often _updateResultsTimer = new ThrottleTimer(500, () => { if (!_cancelled) { // Add the initialized results to the public-facing collection foreach (SearchResultViewModel viewModel in _checkedResults) { if (!_results.Contains(viewModel) && viewModel.IsInitialized) _results.Add(viewModel); } // Update the paged collection of results PagedResults.Refresh(); if (_numberWebResults == _NUMREQUESTS) // All requests have returned { IsSearching = false; // Reset busy state OnSearchCompleted(); // Raise completed event } } }); } _updateResultsTimer.Invoke(); }