From d6d3cdd5739e6b8f8df36bf393e440f4857fb2b7 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:04:58 -0400 Subject: Ava UI: Refactor `async` usage (#5516) * Remove `async void` * Async LoadApplications * Formatting and such * Remove async from InstallUpdate * Update src/Ryujinx.Ava/UI/Controls/ApplicationContextMenu.axaml.cs Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com> * Cleanup LoadApplications() * Cleanup * Formatting * Revert some stuff * Cleanup * Update src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs Co-authored-by: Ac_K * Ack suggestions * Whitespace * Fix Peri suggestion * Add missing trailing commas * Remove redundant method override * Remove Dispatcher.UIThread.InvokeAsync/Post where possible --------- Co-authored-by: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Co-authored-by: Ac_K --- .../UI/Views/Main/MainMenuBarView.axaml.cs | 25 +++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs') diff --git a/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs index af8c4dab..4f2d262d 100644 --- a/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Threading.Tasks; namespace Ryujinx.Ava.UI.Views.Main { @@ -107,20 +106,14 @@ namespace Ryujinx.Ava.UI.Views.Main await Window.ViewModel.AppHost?.ShowExitPrompt(); } - private async void PauseEmulation_Click(object sender, RoutedEventArgs e) + private void PauseEmulation_Click(object sender, RoutedEventArgs e) { - await Task.Run(() => - { - Window.ViewModel.AppHost?.Pause(); - }); + Window.ViewModel.AppHost?.Pause(); } - private async void ResumeEmulation_Click(object sender, RoutedEventArgs e) + private void ResumeEmulation_Click(object sender, RoutedEventArgs e) { - await Task.Run(() => - { - Window.ViewModel.AppHost?.Resume(); - }); + Window.ViewModel.AppHost?.Resume(); } public async void OpenSettings(object sender, RoutedEventArgs e) @@ -132,13 +125,13 @@ namespace Ryujinx.Ava.UI.Views.Main ViewModel.LoadConfigurableHotKeys(); } - public void OpenMiiApplet(object sender, RoutedEventArgs e) + public async void OpenMiiApplet(object sender, RoutedEventArgs e) { string contentPath = ViewModel.ContentManager.GetInstalledContentPath(0x0100000000001009, StorageId.BuiltInSystem, NcaContentType.Program); if (!string.IsNullOrEmpty(contentPath)) { - ViewModel.LoadApplication(contentPath, false, "Mii Applet"); + await ViewModel.LoadApplication(contentPath, false, "Mii Applet"); } } @@ -196,8 +189,7 @@ namespace Ryujinx.Ava.UI.Views.Main { if (FileAssociationHelper.Install()) { - await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogInstallFileTypesSuccessMessage], - string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty); + await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogInstallFileTypesSuccessMessage], string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty); } else { @@ -209,8 +201,7 @@ namespace Ryujinx.Ava.UI.Views.Main { if (FileAssociationHelper.Uninstall()) { - await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogUninstallFileTypesSuccessMessage], - string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty); + await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogUninstallFileTypesSuccessMessage], string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty); } else { -- cgit v1.2.3