diff --git a/ModernKeePass/Actions/NavigateToUrlAction.cs b/ModernKeePass/Actions/NavigateToUrlAction.cs index 9c680f1..ecd4b6c 100644 --- a/ModernKeePass/Actions/NavigateToUrlAction.cs +++ b/ModernKeePass/Actions/NavigateToUrlAction.cs @@ -25,7 +25,7 @@ namespace ModernKeePass.Actions } catch (Exception ex) { - MessageDialogHelper.ShowErrorDialog(ex); + MessageDialogHelper.ShowErrorDialog(ex).Wait(); return false; } } diff --git a/ModernKeePass/App.xaml.cs b/ModernKeePass/App.xaml.cs index 21fea6e..46dea56 100644 --- a/ModernKeePass/App.xaml.cs +++ b/ModernKeePass/App.xaml.cs @@ -39,7 +39,7 @@ namespace ModernKeePass #region Event Handlers - private void OnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) + private async void OnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) { // Save the argument exception because it's cleared on first access var exception = unhandledExceptionEventArgs.Exception; @@ -54,7 +54,7 @@ namespace ModernKeePass if (realException is SaveException) { unhandledExceptionEventArgs.Handled = true; - MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("MessageDialogSaveErrorTitle"), + await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("MessageDialogSaveErrorTitle"), realException.InnerException.Message, resource.GetResourceValue("MessageDialogSaveErrorButtonSaveAs"), resource.GetResourceValue("MessageDialogSaveErrorButtonDiscard"), @@ -90,7 +90,7 @@ namespace ModernKeePass OnLaunchOrActivated(args); } - private void OnLaunchOrActivated(IActivatedEventArgs e) + private async void OnLaunchOrActivated(IActivatedEventArgs e) { #if DEBUG @@ -116,7 +116,7 @@ namespace ModernKeePass { //TODO: Load state from previously terminated application #if DEBUG - MessageDialogHelper.ShowNotificationDialog("App terminated", "Windows or an error made the app terminate"); + await MessageDialogHelper.ShowNotificationDialog("App terminated", "Windows or an error made the app terminate"); #endif } @@ -132,7 +132,7 @@ namespace ModernKeePass Window.Current.Activate(); } - private void OnResuming(object sender, object e) + private async void OnResuming(object sender, object e) { var currentFrame = Window.Current.Content as Frame; var database = DatabaseService.Instance; @@ -151,7 +151,7 @@ namespace ModernKeePass { currentFrame?.Navigate(typeof(MainPage)); #if DEBUG - MessageDialogHelper.ShowErrorDialog(ex); + await MessageDialogHelper.ShowErrorDialog(ex); #endif ToastNotificationHelper.ShowGenericToast("App suspended", "Database was closed (changes were saved)"); } diff --git a/ModernKeePass/Common/MessageDialogHelper.cs b/ModernKeePass/Common/MessageDialogHelper.cs index 3d182cb..385ef4d 100644 --- a/ModernKeePass/Common/MessageDialogHelper.cs +++ b/ModernKeePass/Common/MessageDialogHelper.cs @@ -1,11 +1,12 @@ using System; +using System.Threading.Tasks; using Windows.UI.Popups; namespace ModernKeePass.Common { public static class MessageDialogHelper { - public static async void ShowActionDialog(string title, string contentText, string actionButtonText, string cancelButtonText, UICommandInvokedHandler actionCommand, UICommandInvokedHandler cancelCommand) + public static async Task ShowActionDialog(string title, string contentText, string actionButtonText, string cancelButtonText, UICommandInvokedHandler actionCommand, UICommandInvokedHandler cancelCommand) { // Create the message dialog and set its content var messageDialog = CreateBasicDialog(title, contentText, cancelButtonText, cancelCommand); @@ -17,7 +18,7 @@ namespace ModernKeePass.Common await messageDialog.ShowAsync(); } - public static async void ShowErrorDialog(Exception exception) + public static async Task ShowErrorDialog(Exception exception) { if (exception == null) return; // Create the message dialog and set its content @@ -27,7 +28,7 @@ namespace ModernKeePass.Common await messageDialog.ShowAsync(); } - public static async void ShowNotificationDialog(string title, string message) + public static async Task ShowNotificationDialog(string title, string message) { var dialog = CreateBasicDialog(title, message, "OK"); diff --git a/ModernKeePass/ViewModels/GroupVm.cs b/ModernKeePass/ViewModels/GroupVm.cs index 1ea1b7e..c8c00b9 100644 --- a/ModernKeePass/ViewModels/GroupVm.cs +++ b/ModernKeePass/ViewModels/GroupVm.cs @@ -215,7 +215,7 @@ namespace ModernKeePass.ViewModels } catch (Exception e) { - MessageDialogHelper.ShowErrorDialog(e); + MessageDialogHelper.ShowErrorDialog(e).Wait(); } } @@ -229,7 +229,7 @@ namespace ModernKeePass.ViewModels } catch (Exception e) { - MessageDialogHelper.ShowErrorDialog(e); + MessageDialogHelper.ShowErrorDialog(e).Wait(); } } diff --git a/ModernKeePass/ViewModels/Items/RecentItemVm.cs b/ModernKeePass/ViewModels/Items/RecentItemVm.cs index f9cbd60..5d978c4 100644 --- a/ModernKeePass/ViewModels/Items/RecentItemVm.cs +++ b/ModernKeePass/ViewModels/Items/RecentItemVm.cs @@ -1,4 +1,5 @@ -using Windows.Storage; +using System.Threading.Tasks; +using Windows.Storage; using ModernKeePass.Common; using ModernKeePass.Interfaces; using ModernKeePass.Services; @@ -30,10 +31,10 @@ namespace ModernKeePass.ViewModels public void UpdateAccessTime() { - UpdateAccessTime(RecentService.Instance); + UpdateAccessTime(RecentService.Instance).Wait(); } - public async void UpdateAccessTime(IRecentService recent) + public async Task UpdateAccessTime(IRecentService recent) { await recent.GetFileAsync(Token); } diff --git a/ModernKeePass/Views/EntryDetailPage.xaml.cs b/ModernKeePass/Views/EntryDetailPage.xaml.cs index 4ceafdf..3521112 100644 --- a/ModernKeePass/Views/EntryDetailPage.xaml.cs +++ b/ModernKeePass/Views/EntryDetailPage.xaml.cs @@ -55,14 +55,14 @@ namespace ModernKeePass.Views #endregion - private void DeleteButton_Click(object sender, RoutedEventArgs e) + private async void DeleteButton_Click(object sender, RoutedEventArgs e) { var resource = new ResourcesService(); var message = Model.IsRecycleOnDelete ? resource.GetResourceValue("EntryRecyclingConfirmation") : resource.GetResourceValue("EntryDeletingConfirmation"); var text = Model.IsRecycleOnDelete ? resource.GetResourceValue("EntryRecycled") : resource.GetResourceValue("EntryDeleted"); - MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message, + await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message, resource.GetResourceValue("EntityDeleteActionButton"), resource.GetResourceValue("EntityDeleteCancelButton"), a => { diff --git a/ModernKeePass/Views/GroupDetailPage.xaml.cs b/ModernKeePass/Views/GroupDetailPage.xaml.cs index a006854..a095539 100644 --- a/ModernKeePass/Views/GroupDetailPage.xaml.cs +++ b/ModernKeePass/Views/GroupDetailPage.xaml.cs @@ -97,14 +97,14 @@ namespace ModernKeePass.Views Frame.Navigate(typeof(EntryDetailPage), entry); } - private void DeleteButton_Click(object sender, RoutedEventArgs e) + private async void DeleteButton_Click(object sender, RoutedEventArgs e) { var resource = new ResourcesService(); var message = Model.IsRecycleOnDelete ? resource.GetResourceValue("GroupRecyclingConfirmation") : resource.GetResourceValue("GroupDeletingConfirmation"); var text = Model.IsRecycleOnDelete ? resource.GetResourceValue("GroupRecycled") : resource.GetResourceValue("GroupDeleted"); - MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message, + await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message, resource.GetResourceValue("EntityDeleteActionButton"), resource.GetResourceValue("EntityDeleteCancelButton"), a => { diff --git a/ModernKeePass/Views/UserControls/CompositeKeyUserControl.xaml.cs b/ModernKeePass/Views/UserControls/CompositeKeyUserControl.xaml.cs index fdebffd..a476e34 100644 --- a/ModernKeePass/Views/UserControls/CompositeKeyUserControl.xaml.cs +++ b/ModernKeePass/Views/UserControls/CompositeKeyUserControl.xaml.cs @@ -96,7 +96,7 @@ namespace ModernKeePass.Views.UserControls var resource = new ResourcesService(); if (database.IsOpen) { - MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("MessageDialogDBOpenTitle"), + await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("MessageDialogDBOpenTitle"), string.Format(resource.GetResourceValue("MessageDialogDBOpenDesc"), database.Name), resource.GetResourceValue("MessageDialogDBOpenButtonSave"), resource.GetResourceValue("MessageDialogDBOpenButtonDiscard"),