public override void Start(FrameBase frameBase) { var frame = frameBase as KillFrame; if (frame == null) { return; } Process process = ProcessList.Get(frame.Guid); if (process != null) { try { process.Kill(); } catch { } } }
public override async void Start(FrameBase frameBase) { var frame = frameBase as RequestFrame; if (frame == null) { return; } Process process = new Process(); process.StartInfo.FileName = Common.Tools.Environment.ReplaceEnvironmentVars(frame.FileName); process.StartInfo.Arguments = Common.Tools.Environment.ReplaceEnvironmentVars(frame.Arguments); process.StartInfo.Verb = "runas"; if (frame.Hide) { process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; } if (frame.RedirectInput) { process.StartInfo.RedirectStandardInput = true; } if (frame.RedirectOutput) { process.StartInfo.RedirectStandardOutput = true; } if (frame.RedirectError) { process.StartInfo.RedirectStandardError = true; } if (frame.StartUtc.Ticks > 0) { TimeSpan startDelay = frame.StartUtc - DateTime.UtcNow; if (startDelay.Ticks > 0) { await Task.Delay(startDelay).ConfigureAwait(false); } } ProcessList.Add(frame.Guid, process); try { process.Start(); if (frame.RedirectOutput) { ReadOutput(frame, process); } if (frame.RedirectError) { ReadError(frame, process); } if (frame.StopUtc.Ticks > 0) { KillTask(frame.StopUtc, process); } } catch (Exception ex) { } RemoveInstanceWhenExited(frame, process); }