Launcher

Launching and Process Control

Methods for launching the executable, waiting for it to complete, killing it, redirecting its output, and checking if it is running.

Methods for launching the executable, waiting for it to complete, killing it, redirecting its output, and checking if it is running.

Launch starts the configured executable and returns the Launcher instance. WaitForExit pauses execution until the process exits or the timeout (in milliseconds) elapses. Kill terminates the process. KillTree terminates the process and all child processes it spawned. IsRunning checks whether the process is currently active. RedirectOutput captures standard output to an Action<string> callback - called once per output line. RedirectError captures standard error output the same way.

Examples

GPAL Fluent: High-level fluent C# API

//WaitForExit takes a timeout in milliseconds. RedirectOutput and RedirectError must be called before Launch to capture output - calling them after Launch will not capture output from the already-running process.

// Launch and wait for completion GPAL.Launcher .WithExecutable("C:\scripts\process.exe") .WithArgument("--input=data.csv") .Launch() .WaitForExit(30000); // 30 second timeout // Launch and capture output GPAL.Launcher .WithExecutable("C:\tools\report.exe") .RedirectOutput(line => Console.WriteLine("OUT: " + line)) .RedirectError(line => Console.WriteLine("ERR: " + line)) .Launch() .WaitForExit(60000); // Check if running before killing var launcher = GPAL.Launcher .WithExecutable("C:\apps\worker.exe") .Launch() .ToGPALObject(); if (launcher.IsRunning().GetType() != null) { launcher.Kill(); }