private async Task InitializeAsync() { try { await Task.Run(() => { _audioSourceLoader.LoadAudioSources(); Options.ContextMenuItems = BuildContextMenu(); InitializeModels(); }).ConfigureAwait(false); _settingsWindowVm = await SetupViewModels().ConfigureAwait(false); await _uiDispatcher.InvokeAsync(() => { _settingsWindow = new SettingsWindow(_settingsWindowVm); _settingsWindow.Saved += Saved; _settingsWindow.Canceled += Canceled; ElementHost.EnableModelessKeyboardInterop(_settingsWindow); }); await SelectAudioSourceFromSettings().ConfigureAwait(false); Logger.Debug("Initialization complete"); } catch (Exception e) { Logger.Error(e); } }
private async Task InitializeAsync() { try { Logger.Debug("Initialization started"); await Task.Run(() => { _audioSourceContextMenuItems = new List <DeskBandMenuAction>(); _settingsMenuItem = new DeskBandMenuAction("Audio Band Settings"); _settingsMenuItem.Clicked += SettingsMenuItemOnClicked; RefreshContextMenu(); InitializeModels(); }).ConfigureAwait(false); _settingsWindowVm = await SetupViewModels().ConfigureAwait(false); await _uiDispatcher.InvokeAsync(() => { _settingsWindow = new SettingsWindow(_settingsWindowVm); _settingsWindow.Saved += SettingsWindowOnSaved; _settingsWindow.Canceled += SettingsWindowOnCanceled; ElementHost.EnableModelessKeyboardInterop(_settingsWindow); }); _audioSourceManager = new AudioSourceManager(); _audioSourceManager.AudioSources.CollectionChanged += AudioSourcesOnCollectionChanged; _audioSourceManager.LoadAudioSources(); Logger.Debug("Initialization complete"); } catch (Exception e) { Logger.Error(e, "Error during initialization"); } }