private void UpdateSubscriptionStatusUI(bool newStatus)
        {
            if (newStatus)
            {
                viewModel.SubscriptionStatus = string.Format("Subscription: {0}", JSONStructures.SubscriptionStatus.Active);
            }
            else
            {
                viewModel.SubscriptionStatus = string.Format("Subscription: {0}", JSONStructures.SubscriptionStatus.Inactive);

                // Log the user out when their subscription is inactive
                Manager.Account.Logout(removeDevice: false);

                // Navigate the user to the sign in screen and display subscription expired toast
                Application.Current.Dispatcher.Invoke(() =>
                {
                    var owner = Application.Current.MainWindow;
                    if (owner != null)
                    {
                        ((UI.MainWindow)owner).NavigateToView(new UI.LinkAccountView(), UI.MainWindow.SlideDirection.Right);

                        // Create a subscription expired toast
                        var message = new ErrorHandling.UserFacingMessage(
                            "toast-no-subscription",
                            new ErrorHandling.UserFacingMessage[] { new ErrorHandling.UserFacingMessage("subscribe-url-title", new List <Type>()
                            {
                                typeof(Underline), typeof(Bold)
                            }) }
                            );

                        var toast = new UI.Components.Toast.Toast(UI.Components.Toast.Style.Info, message, priority: UI.Components.Toast.Priority.Important)
                        {
                            ClickEventHandler = (sender, e) =>
                            {
                                Process.Start(ProductConstants.SubscriptionUrl);
                            },
                        };

                        // Display the subscription expired toast
                        Manager.ToastManager.Show(toast);
                    }
                });
            }
        }
        private async void UpdateVersionAsync(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                JSONStructures.BalrogResponse balrogResponse;

                try
                {
                    balrogResponse = await Update.Balrog.QueryUpdate(ProductConstants.GetNumericVersion());
                }
                catch (Exception e)
                {
                    if (e is HttpRequestException)
                    {
                        cancellationToken.WaitHandle.WaitOne(TimeSpan.FromMinutes(5));
                        continue;
                    }
                    else
                    {
                        ErrorHandling.ErrorHandler.Handle(e, ErrorHandling.LogLevel.Error);
                        throw e;
                    }
                }

                if (balrogResponse != null)
                {
                    if (balrogResponse.Required)
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            var owner = Application.Current.MainWindow;
                            if (owner != null)
                            {
                                ((UI.MainWindow)owner).NavigateToView(new UI.UpdateView(), UI.MainWindow.SlideDirection.Right);
                                Manager.MustUpdate = true;
                            }
                        });
                    }
                    else
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            if (Manager.MainWindowViewModel.UpdateToast == null)
                            {
                                // Create an update toast
                                var message = new ErrorHandling.UserFacingMessage(
                                    "toast-update-version-message-1",
                                    new ErrorHandling.UserFacingMessage[] { new ErrorHandling.UserFacingMessage("toast-update-version-message-2", new List <Type>()
                                    {
                                        typeof(Underline), typeof(Bold)
                                    }) }
                                    );

                                var toast = new UI.Components.Toast.Toast(UI.Components.Toast.Style.Info, message, display: UI.Components.Toast.Display.Persistent, priority: UI.Components.Toast.Priority.Important)
                                {
                                    ClickEventHandler = (sender, e) =>
                                    {
                                        // Create an update toast
                                        var updateToast = new UI.Components.Toast.Toast(UI.Components.Toast.Style.Info, new ErrorHandling.UserFacingMessage("update-update-started"), priority: UI.Components.Toast.Priority.Important);
                                        Manager.ToastManager.Show(updateToast);
                                        ErrorHandling.ErrorHandler.WriteToLog(Manager.TranslationService.GetString("update-update-started"), ErrorHandling.LogLevel.Info);

                                        var updateTask = Task.Run(async() =>
                                        {
                                            var success = await Update.Update.Run(ProductConstants.GetNumericVersion());
                                            if (success)
                                            {
                                                // Dismiss the update toast
                                                Application.Current.Dispatcher.Invoke(() =>
                                                {
                                                    Manager.MainWindowViewModel.UpdateToast.Toast_Dismiss(null, null);
                                                });
                                            }
                                            else
                                            {
                                                ErrorHandling.ErrorHandler.Handle(new ErrorHandling.UserFacingMessage("update-update-failed"), ErrorHandling.UserFacingErrorType.Toast, ErrorHandling.UserFacingSeverity.ShowError, ErrorHandling.LogLevel.Error);
                                            }
                                        });
                                    },
                                };

                                Manager.MainWindowViewModel.UpdateToast = toast;
                            }

                            var owner = Application.Current.MainWindow;
                            if (owner != null)
                            {
                                // Show the update toast
                                Manager.ToastManager.Show(Manager.MainWindowViewModel.UpdateToast);
                            }
                        });
                    }
                }

                cancellationToken.WaitHandle.WaitOne(TimeSpan.FromHours(6));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Toast"/> class.
 /// </summary>
 /// <param name="style">Visual style variation of the toast.</param>
 /// <param name="message">Message to be displayed to the user.</param>
 /// <param name="ownerId">Id of the XAML control that the toast will be displayed within.</param>
 /// <param name="display">Display mode of the toast.</param>
 /// <param name="duration">Display duration for the toast.  Only relevant for ephemeral toasts.</param>
 /// <param name="priority">Display priority of the toast.</param>
 public Toast(Style style, ErrorHandling.UserFacingMessage message, string ownerId = "", Display display = DefaultDisplay, TimeSpan? duration = null, Priority priority = DefaultPriority)
 {
     this.Message = message;
     Content = message.TextBlock;
     Initialize(style, Content, ownerId, display, duration, priority);
 }