Exemple #1
0
        // 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();
        }