Manages the logical workflow of the application. Creates and deploys PageManagers. Returns WorkProgress object to report status and successful results.
Наследование: System.ComponentModel.BackgroundWorker
Пример #1
0
        /// <summary>
        /// Validates controls, obtains the control values, and begins the
        /// asynchronous scraping / parsing / result handling process.
        /// </summary>
        private void Search()
        {
            // Validate the search controls.
            Result <bool> result = ValidateControls();

            if (result.ErrorMessage.Length > 0)
            {
                MessageBox.Show(result.ErrorMessage);
                return;
            }

            SearchCriteria searchCriteria = GetSearchCriteria();

            // Replace the search controls with the progress control(s)
            ShowSearchProgressGrid();

            StatusTextBox.Text = "Loading results. Please be patient.";
            Progress.Value     = 0;
            ResultGrid.Items.Clear();

            // Stop any previous search if it's still working
            // (in practice this should not be necessary)
            if (_searchManager != null && _searchManager.IsBusy)
            {
                string msg = "Please wait one moment before searching. ";
                MessageBox.Show(msg);
                _searchManager.CancelAsync();
            }

            // Coordinates the actual scraping/parsing/validation/results:
            _searchManager = new SearchManager(searchCriteria,
                                               Constants.MAX_THREADS);
            _searchManager.ProgressChanged    += ScraperProgressChanged;
            _searchManager.RunWorkerCompleted += ScrapeComplete;
            _searchManager.RunWorkerAsync();
        }
Пример #2
0
        /// <summary>
        /// Validates controls, obtains the control values, and begins the 
        /// asynchronous scraping / parsing / result handling process.
        /// </summary>
        private void Search()
        {
            // Validate the search controls.
            Result<bool> result = ValidateControls();

            if (result.ErrorMessage.Length > 0)
            {
                MessageBox.Show(result.ErrorMessage);
                return;
            }

            SearchCriteria searchCriteria = GetSearchCriteria();

            // Replace the search controls with the progress control(s)
            ShowSearchProgressGrid();

            StatusTextBox.Text = "Loading results. Please be patient.";
            Progress.Value = 0;
            ResultGrid.Items.Clear();

            // Stop any previous search if it's still working
            // (in practice this should not be necessary)
            if (_searchManager != null && _searchManager.IsBusy)
            {
                string msg = "Please wait one moment before searching. ";
                MessageBox.Show(msg);
                _searchManager.CancelAsync();
            }

            // Coordinates the actual scraping/parsing/validation/results:
            _searchManager = new SearchManager(searchCriteria,
                Constants.MAX_THREADS);
            _searchManager.ProgressChanged += ScraperProgressChanged;
            _searchManager.RunWorkerCompleted += ScrapeComplete;
            _searchManager.RunWorkerAsync();
        }