private void _searchBtn_Click(object sender, EventArgs e)
        {
            var search = searchTB.Text;

            if (search == null || search.Trim().Length == 0)
            {
                return;
            }

            PrepareSearch(sender, e);

            ThreadHelper.JoinableTaskFactory.RunAsync(
                async() =>
            {
                try
                {
                    await TaskScheduler.Default;

                    var repositories = _gitHoster.SearchForRepository(search);

                    await this.SwitchToMainThreadAsync();

                    HandleSearchResult(repositories);
                }
                catch (Exception ex) when(!(ex is OperationCanceledException))
                {
                    await this.SwitchToMainThreadAsync();

                    MessageBox.Show(this, _strSearchFailed.Text + Environment.NewLine + ex.Message, _strError.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    searchBtn.Enabled = true;
                }
            })
            .FileAndForget();
        }
Example #2
0
        private void _searchBtn_Click(object sender, EventArgs e)
        {
            var search = _searchTB.Text;

            if (search == null || search.Trim().Length == 0)
            {
                return;
            }

            PrepareSearch(sender, e);

            AsyncHelpers.DoAsync(
                () => _gitHoster.SearchForRepository(search),
                HandleSearchResult,
                ex => { MessageBox.Show(this, _strSearchFailed.Text + ex.Message, _strError.Text); _searchBtn.Enabled = true; });
        }