async Task ISectionViewModel.InitializeAsync(ITeamExplorerUtils teamExplorerService) { // When the user switches to TeamExplorer immediately after opening Visual Studio, // sometimes, GoogleCloudExtensionPackage is not initialized. This is a hack to // retry until the instance is initialized. int retryAttempts = 3; while (retryAttempts > 0 && GoogleCloudExtensionPackage.Instance == null) { await Task.Delay(2000); retryAttempts--; } if (GoogleCloudExtensionPackage.Instance == null) { teamExplorerService.ShowError(Resources.FailedLoadingCsr); return; } EventsReporterWrapper.ReportEvent(CsrConnectSectionOpenEvent.Create()); Debug.WriteLine("CsrSectionControlViewModel Initialize"); _teamExplorerService = teamExplorerService.ThrowIfNull(nameof(teamExplorerService)); _reposViewModel = new CsrReposViewModel(_teamExplorerService); _reposContent.DataContext = _reposViewModel; _unconnectedViewModel = new CsrUnconnectedViewModel(this); _unconnectedContent.DataContext = _unconnectedViewModel; _gitSetupViewModel = new CsrGitSetupWarningViewModel(this); _gitSetupContent.DataContext = _gitSetupViewModel; if (!CsrGitSetupWarningViewModel.GitInstallationVerified) { ErrorHandlerUtils.HandleExceptionsAsync(CheckGitInstallationAsync); } else { OnGitInstallationCheckSuccess(); } }
void ISectionViewModel.Initialize(ITeamExplorerUtils teamExplorerService) { EventsReporterWrapper.ReportEvent(CsrConnectSectionOpenEvent.Create()); Debug.WriteLine("CsrSectionControlViewModel Initialize"); _teamExplorerService = teamExplorerService.ThrowIfNull(nameof(teamExplorerService)); _reposViewModel = new CsrReposViewModel(_teamExplorerService); _reposContent.DataContext = _reposViewModel; _unconnectedViewModel = new CsrUnconnectedViewModel(this); _unconnectedContent.DataContext = _unconnectedViewModel; _gitSetupViewModel = new CsrGitSetupWarningViewModel(this); _gitSetupContent.DataContext = _gitSetupViewModel; if (!CsrGitSetupWarningViewModel.GitInstallationVerified) { ErrorHandlerUtils.HandleExceptionsAsync(CheckGitInstallationAsync); } else { OnGitInstallationCheckSuccess(); } }