Exemplo n.º 1
0
        private void UpdateMyRepos()
        {
            myReposLV.Items.Clear();
            myReposLV.Items.Add(new ListViewItem {
                Text = _strLoading.Text
            });

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

                    var repos = _gitHoster.GetMyRepos();

                    await this.SwitchToMainThreadAsync();

                    myReposLV.Items.Clear();

                    foreach (var repo in repos.OrderBy(r => r.Name))
                    {
                        myReposLV.Items.Add(new ListViewItem
                        {
                            Tag      = repo,
                            Text     = repo.Name,
                            SubItems =
                            {
                                repo.IsAFork?Strings.Yes : Strings.No,
                                repo.Forks.ToString(),
                                repo.IsPrivate ? Strings.Yes : Strings.No
                            }
                        });
                    }

                    ResizeColumnToFitContent(myReposLV.Columns[0]);
                }
                catch (Exception ex) when(!(ex is OperationCanceledException))
                {
                    await this.SwitchToMainThreadAsync();

                    myReposLV.Items.Clear();
                    helpTextLbl.Text = string.Format(_strFailedToGetRepos.Text, _gitHoster.Description) +
                                       "\r\n\r\nException: " + ex.Message + "\r\n\r\n" + helpTextLbl.Text;
                }
            })
            .FileAndForget();
        }
Exemplo n.º 2
0
        private void UpdateMyRepos()
        {
            _myReposLV.Items.Clear();
            _myReposLV.Items.Add(new ListViewItem {
                Text = _strLoading.Text
            });

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

                    var repos = _gitHoster.GetMyRepos();

                    await this.SwitchToMainThreadAsync();

                    _myReposLV.Items.Clear();

                    foreach (var repo in repos)
                    {
                        _myReposLV.Items.Add(new ListViewItem
                        {
                            Tag      = repo,
                            Text     = repo.Name,
                            SubItems =
                            {
                                repo.IsAFork?_strYes.Text : _strNo.Text,
                                repo.Forks.ToString(),
                                repo.IsPrivate ? _strYes.Text : _strNo.Text
                            }
                        });
                    }
                }
                catch (Exception ex) when(!(ex is OperationCanceledException))
                {
                    await this.SwitchToMainThreadAsync();

                    _myReposLV.Items.Clear();
                    _helpTextLbl.Text = string.Format(_strFailedToGetRepos.Text, _gitHoster.Description) +
                                        "\r\n\r\nException: " + ex.Message + "\r\n\r\n" + _helpTextLbl.Text;
                }
            })
            .FileAndForget();
        }