void Starting(object sender, StartupEventArgs e) { string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) { switch (args[1]) { case "--nextbackground": try { var wallpaper = (IDesktopWallpaper) new DesktopWallpaper(); wallpaper.AdvanceSlideshow(null, DesktopSlideshowDirection.Forward); } catch (System.Runtime.InteropServices.COMException ex) { } Environment.Exit(0); break; case "--autostart": lazyStart = true; break; } } if (lazyStart) { if (Settings.Default.Hotspot == null) { return; } hotspot = new Hotspot(null); Task.Delay(5000).ContinueWith(async(dontCare) => { var connect = await hotspot.Connect(Settings.Default.Hotspot); if (connect != Hotspot.Status.Connected) { DebugHelper.File("Fail to auto hotspot"); } Environment.Exit(0); }); } else { MainWindow mainWindow = new MainWindow(); MainWindow = mainWindow; mainWindow.Show(); } }