public override Task DeactivateAsync(IDictionary <string, object> pageState) { if (_backgroundTaskOptionsChanged) { if (BackgroundTaskIsEnabled) { _loggingService.WriteLine("The background task options were changed. Re-registering the background task."); _backgroundTaskService.UnregisterBackgroundTask(); return(_backgroundTaskService.RegisterBackgroundTaskAsync()); } else { _loggingService.WriteLine("The background task options were changed. Unregistering the background task."); _backgroundTaskService.UnregisterBackgroundTask(); } } return(Task.FromResult(true)); }