/// <summary> /// Handles the ContentRendered event of the Window control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void Window_ContentRendered(object sender, EventArgs e) { this.progressBar.Visibility = Visibility.Visible; Thread subscriptionThread = new Thread(new ThreadStart(() => { try { TokenCredentials tokenCredentials = new TokenCredentials(this.authResult.AccessToken); RM.SubscriptionClient subsClient = new RM.SubscriptionClient(tokenCredentials); List <RM.Models.SubscriptionInner> subscriptionList = new List <RM.Models.SubscriptionInner>(); var resp = subsClient.Subscriptions.List(); subscriptionList.AddRange(resp); while (!string.IsNullOrEmpty(resp.NextPageLink)) { resp = subsClient.Subscriptions.ListNext(resp.NextPageLink); subscriptionList.AddRange(resp); } this.Dispatcher.Invoke(() => { this.subscriptions.Clear(); subscriptionList.ForEach(sub => this.subscriptions.Add(sub)); this.comboSubscriptionList.IsEnabled = true; this.progressBar.Visibility = Visibility.Hidden; }); } catch (Exception ex) { Logger.LogError(CallInfo.Site(), ex, "Failed to get user subscriptions"); this.Dispatcher.Invoke(() => MessageBox.Show("Failed to get list of subscriptons!! Exiting", "Azure Error", MessageBoxButton.OKCancel, MessageBoxImage.Error)); Application.Current.Shutdown(); } })); subscriptionThread.Start(); }