private void CancelLaunch_Click(object sender, RoutedEventArgs e) { AppEntry app = (sender as Control)?.DataContext as AppEntry; if (app != null) { app.Phase = LaunchPhase.Done; } }
private void Launch_Click(object sender, RoutedEventArgs e) { AppEntry app = (sender as Control)?.DataContext as AppEntry; if (app != null) { StartLaunching(app); } }
private void BeginAppCooldown(AppEntry app, bool first) { if (mConfig.FirstIsSpecial) { app.ExecuteTick = first ? Environment.TickCount : Environment.TickCount + (1000 * app.Timeout); } else { app.ExecuteTick = Environment.TickCount + (1000 * app.Timeout); } app.Phase = LaunchPhase.Next; }
private void StartLaunching(AppEntry app) { app.Phase = LaunchPhase.Launching; app.LaunchDate = DateTime.Now; try { app.Process = Process.Start(new ProcessStartInfo(app.FullPath) { UseShellExecute = true }); } catch (Exception) { app.Phase = LaunchPhase.Error; } }
private bool IsAppReady(AppEntry app) { if (app.Process == null) { return(true); } if (app.Process.HasExited) { return(true); } try { return(app.Process.WaitForInputIdle(0)); } catch (InvalidOperationException) { return(true); } }
private bool IsCooldownOver(AppEntry app) { return(app.ExecuteTick != 0 && (Environment.TickCount - app.ExecuteTick) > 0); }