private async void Window_Loaded(object sender, RoutedEventArgs e) { string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray(); try { serviceBuilder.WithArgs(args); } catch (Exception exc) { MessageBox.Show(exc.Message, "Create service builder error"); Close(); return; } try { hotKeysBuilder.WithArgs(args); } catch (Exception exc) { MessageBox.Show(exc.Message, "Create hotkeys builder error"); Close(); throw; } Option disableUiOpt = Option.GetLongOnly("disable-ui", "Disables UI on startup.", false, 0); OptionParseResult result = new Options(disableUiOpt).Parse(args); if (result.TryGetFirstValidOptionParseds(disableUiOpt, out _)) { viewModel.IsUiEnabled = false; } IntPtr windowHandle = new WindowInteropHelper(this).Handle; serviceBuilder.WithPlayer(new Player(-1, windowHandle)) .WithCommunicatorHelper(new InvokeDispatcherHelper(Dispatcher)); await BuildAudioServiceAsync(); BuildHotKeys(); }