From c721d84f5631687ba3fa3ea5007c8b90bfb48e07 Mon Sep 17 00:00:00 2001 From: Felix Date: Wed, 3 Apr 2024 10:24:12 +0200 Subject: [PATCH] Revert "Fixed ThrowIfNotOnUIThread exception (see #163)" This reverts commit 2ac8e16638a2ee1d128708b98f70582564050f3e. --- SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsPackage.cs | 2 +- .../Services/OptionsSettingsService.cs | 8 ++++---- .../SmartCmdArgs.Shared/ViewModel/SettingsViewModel.cs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsPackage.cs b/SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsPackage.cs index e43d38c3..630a9028 100644 --- a/SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsPackage.cs +++ b/SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsPackage.cs @@ -167,7 +167,7 @@ private ServiceProvider ConfigureServices() var services = new ServiceCollection(); services.AddSingleton(); - services.AddSingleton(x => GetDialogPage()); + services.AddLazySingleton(x => GetDialogPage()); services.AddLazySingleton(); services.AddLazySingleton(); services.AddLazySingleton(); diff --git a/SmartCmdArgs/SmartCmdArgs.Shared/Services/OptionsSettingsService.cs b/SmartCmdArgs/SmartCmdArgs.Shared/Services/OptionsSettingsService.cs index de0ab2b8..e3fe3a08 100644 --- a/SmartCmdArgs/SmartCmdArgs.Shared/Services/OptionsSettingsService.cs +++ b/SmartCmdArgs/SmartCmdArgs.Shared/Services/OptionsSettingsService.cs @@ -38,19 +38,19 @@ internal class OptionsSettingsService : PropertyChangedBase, IOptionsSettingsSer { private readonly IVisualStudioHelperService _vsHelperService; private readonly SettingsViewModel settingsViewModel; - private readonly CmdArgsOptionPage optionPage; + private readonly Lazy lazyOptionsPage; public OptionsSettingsService( IVisualStudioHelperService vsHelperService, SettingsViewModel settingsViewModel, - CmdArgsOptionPage optionPage) + Lazy lazyOptionsPage) { _vsHelperService = vsHelperService; this.settingsViewModel = settingsViewModel; - this.optionPage = optionPage; + this.lazyOptionsPage = lazyOptionsPage; } - private CmdArgsOptionPage OptionsPage => optionPage; + private CmdArgsOptionPage OptionsPage => lazyOptionsPage.Value; // Settings (possibly with options default) public bool SaveSettingsToJson => settingsViewModel.SaveSettingsToJson; diff --git a/SmartCmdArgs/SmartCmdArgs.Shared/ViewModel/SettingsViewModel.cs b/SmartCmdArgs/SmartCmdArgs.Shared/ViewModel/SettingsViewModel.cs index 2af2b54b..e6341717 100644 --- a/SmartCmdArgs/SmartCmdArgs.Shared/ViewModel/SettingsViewModel.cs +++ b/SmartCmdArgs/SmartCmdArgs.Shared/ViewModel/SettingsViewModel.cs @@ -8,7 +8,7 @@ namespace SmartCmdArgs.ViewModel { public class SettingsViewModel : PropertyChangedBase { - private readonly CmdArgsOptionPage optionPage; + private readonly Lazy optionPage; private readonly Lazy lifeCycleService; private bool _saveSettingsToJson; private bool? _manageCommandLineArgs; @@ -83,13 +83,13 @@ public bool? MacroEvaluationEnabled public RelayCommand DisableExtensionCommand { get; } - public CmdArgsOptionPage Options => optionPage; + public CmdArgsOptionPage Options => optionPage.Value; public ILifeCycleService LifeCycle => lifeCycleService.Value; public RelayCommand OpenOptionsCommand { get; } public SettingsViewModel( - CmdArgsOptionPage optionPage, + Lazy optionPage, Lazy lifeCycleService) { this.optionPage = optionPage;