private void SearchBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { var request = (TablatureSearchRequest)e.Argument; var proxy = TabsterSettingsUtilities.ProxySettings.Proxy; foreach (var engine in request.SearchEngines) { try { var results = engine.Search(request, proxy); if (results != null) { request.Results.AddRange(results); for (var i = 0; i < results.Length; i++) { SearchBackgroundWorker.ReportProgress(i, results[i]); } } } catch { //unhandled } } }
private void menuItemExit_Click(object sender, EventArgs e) { if (SearchBackgroundWorker.IsBusy) { SearchBackgroundWorker.CancelAsync(); } Application.Exit(); }
private void SearchButton_Click(object sender, EventArgs e) { if (ResultsListView.Focused) { // submit will show messages if results view has focus ShowSelectedUsers(); } else if (this.IsSearching) { // if searching, stop the search this.IsSearching = false; SearchBackgroundWorker.CancelAsync(); } else { // perform search this.IsSearching = true; this.SearchButton.Text = "Stop"; this.statusStrip.Visible = true; int statusHeight = this.statusStrip.Height; this.MinimumSize = new Size(_originalSize.Width, _originalSize.Height + statusHeight); int preferredHeight = this.MinimumSize.Height * 2 + statusHeight; if (this.Height < preferredHeight) { this.Size = new Size(this.Width, preferredHeight); } if (!SearchBackgroundWorker.IsBusy) // BUGFIX #36: check bg worker status before invoking { // search by properties this.ResultsListView.Items.Clear(); this.ResultsListView.Cursor = Cursors.WaitCursor; this.toolStripStatusLabel.Text = "Searching..."; Application.DoEvents(); this.ResultsListView.BeginUpdate(); SearchBackgroundWorker.RunWorkerAsync(new SearchParameters() { Name = _displayNameTextBox.Text, Email = _emailTextBox.Text, CandidateID = _candidatePicker.SelectedCid, ElectionCycle = _electionPicker.SelectedElection == null ? null : _electionPicker.SelectedElection.Cycle, GroupID = _groupComboBox.SelectedGroup, Disabled = _disabledCheckBox.CheckState == CheckState.Indeterminate ? null : (bool?)(_disabledCheckBox.Checked), Locked = _lockedCheckBox.CheckState == CheckState.Indeterminate ? null : (bool?)(_lockedCheckBox.Checked), Used = _loggedInCheckBox.CheckState == CheckState.Indeterminate ? null : (bool?)(_loggedInCheckBox.Checked), CreationStartDate = _createStartDatePicker.Enabled ? (DateTime?)_createStartDatePicker.Value.Date : null, CreationEndDate = _createEndDatePicker.Enabled ? (DateTime?)_createEndDatePicker.Value.Date : null, }); } } }
private void SearchButton_Click(object sender, EventArgs e) { if (ResultsListView.Focused) { // submit will show messages if results view has focus ShowSelectedMessages(); } else if (this.IsSearching) { // if searching, stop the search this.IsSearching = false; SearchBackgroundWorker.CancelAsync(); } else { // perform search this.IsSearching = true; this.SearchButton.Text = "Stop"; this.statusStrip.Visible = true; int statusHeight = this.statusStrip.Height; this.MinimumSize = new Size(_originalSize.Width, _originalSize.Height + statusHeight); int preferredHeight = this.MinimumSize.Height * 2 + statusHeight; if (this.Height < preferredHeight) { this.Size = new Size(this.Width, preferredHeight); } if (!SearchBackgroundWorker.IsBusy) // BUGFIX #36: check bg worker status before invoking { // search by properties this.ResultsListView.Items.Clear(); this.ResultsListView.Cursor = Cursors.WaitCursor; this.toolStripStatusLabel.Text = "Searching..."; Application.DoEvents(); this.ResultsListView.BeginUpdate(); SearchBackgroundWorker.RunWorkerAsync(new SearchParameters() { CandidateID = _candidatePicker.SelectedCid, ElectionCycle = _electionPicker.SelectedElection == null ? null : _electionPicker.SelectedElection.Cycle, Creator = _cfbEmployeePicker.SelectedEmployee, Category = _categoryComboBox.SelectedCategory, Title = string.IsNullOrEmpty(_subjectTextBox.Text) ? null : _subjectTextBox.Text, Body = string.IsNullOrEmpty(_bodyTextBox.Text) ? null : _bodyTextBox.Text, PostedStartDate = _postedStartDatePicker.Enabled ? (DateTime?)_postedStartDatePicker.Value.Date : null, PostedEndDate = _postedEndDatePicker.Enabled ? (DateTime?)_postedEndDatePicker.Value.Date : null, Opened = _openedCheckBox.CheckState == CheckState.Indeterminate ? null : (bool?)_openedCheckBox.Checked, HasAttachments = _attachmentsCheckBox.CheckState == CheckState.Indeterminate ? null : (bool?)_attachmentsCheckBox.Checked, }); } } }
private void btnSearch_Click(object sender, EventArgs e) { if (textBox1.Text.Length > 0) { var cat = cbCategories.SelectedIndex == 0 ? null : new Category(cbCategories.Text); var subCat = cbSubcategories.SelectedIndex == 0 ? null : new Subcategory(cbSubcategories.Text); var query = new SearchQuery(cat, subCat); if (!SearchBackgroundWorker.IsBusy) { SearchBackgroundWorker.RunWorkerAsync(query); } } }
private void onlinesearchbtn_Click(object sender, EventArgs e) { if (txtSearchArtist.Text.Trim().Length > 0 || txtSearchTitle.Text.Trim().Length > 0) { onlinesearchbtn.Enabled = false; listViewSearch.ClearObjects(); searchPreviewEditor.Clear(); var request = CreateSearchRequest(); if (request != null) { SearchBackgroundWorker.RunWorkerAsync(request); } } }