public ServiceBase(IServiceStartInfo startInfo) { this.StartInfo = startInfo; this.Log = new Logger(startInfo.Name, startInfo.EnableLog); this.InnerThread = new Thread(new ThreadStart(this.ThreadProc)); this.InnerThread.IsBackground = true; this.IsRunning = false; }
public LaunchService(IServiceStartInfo startInfo) : base(startInfo) { this.InnerProcess = new Process(); this.InnerProcess.StartInfo.UseShellExecute = startInfo.UseShellExecute; this.InnerProcess.StartInfo.FileName = startInfo.Command; this.InnerProcess.StartInfo.Arguments = startInfo.Arguments; this.InnerProcess.StartInfo.WorkingDirectory = startInfo.WorkingDirectory; this.Log.Info("InnerProcess is created"); this.ResolveProcessBeforeStart(this.InnerProcess); }
public IntervalService(IServiceStartInfo startInfo) : base(startInfo) { this.InnerProcess = new Process(); this.InnerProcess.StartInfo.UseShellExecute = startInfo.UseShellExecute; this.InnerProcess.StartInfo.FileName = startInfo.Command; this.InnerProcess.StartInfo.Arguments = startInfo.Arguments; this.InnerProcess.StartInfo.WorkingDirectory = startInfo.WorkingDirectory; this.Log.Info("InnerProcess is created"); this.ResolveProcessBeforeStart(this.InnerProcess); }
public IService Create(IServiceStartInfo startInfo) { switch (startInfo.RunMode) { case ServiceRunMode.Daemon: return new DaemonService(startInfo) as IService; case ServiceRunMode.Launch: return new LaunchService(startInfo) as IService; case ServiceRunMode.Interval: return new IntervalService(startInfo) as IService; default: throw new ArgumentOutOfRangeException("runMode"); } }
public IService Create(IServiceStartInfo startInfo) { switch (startInfo.RunMode) { case ServiceRunMode.Launch: return(new LaunchService(startInfo) as IService); case ServiceRunMode.Interval: return(new IntervalService(startInfo) as IService); case ServiceRunMode.Daemon: default: return(new DaemonService(startInfo) as IService); } }
public ServiceBase(IServiceStartInfo startInfo) { this.StartInfo = startInfo; this.Log = new Logger(startInfo.Name, startInfo.EnableLog); this.InnerThread = new Thread(new ThreadStart(this.ThreadProc)); this.InnerThread.IsBackground = true; this.IsRunning = false; if (startInfo.KillExistingProcess) { Process.GetProcesses().Where(p => this.TryMatchProcess(p, startInfo.Command)) .ToList() .ForEach(p => this.TryKillProcess(p)); } }
public IService Create(IServiceStartInfo startInfo) { switch (startInfo.RunMode) { case ServiceRunMode.Daemon: return(new DaemonService(startInfo) as IService); case ServiceRunMode.Launch: return(new LaunchService(startInfo) as IService); case ServiceRunMode.Interval: return(new IntervalService(startInfo) as IService); default: throw new ArgumentOutOfRangeException("runMode"); } }
public bool StartCaptureService(IServiceStartInfo startinfo) { if (!CaptureServiceInfo.IsCompatibleWithRunningOS) { return(false); } try { TryKillPresentMon(); SubscribeToPresentMonCapturedProcesses(); Process process = new Process { StartInfo = new ProcessStartInfo { FileName = startinfo.FileName, Arguments = startinfo.Arguments, UseShellExecute = startinfo.UseShellExecute, RedirectStandardOutput = true, RedirectStandardError = true, RedirectStandardInput = true, // is it a MUST?? CreateNoWindow = startinfo.CreateNoWindow, Verb = "runas", } }; process.EnableRaisingEvents = true; process.OutputDataReceived += (sender, e) => _outputDataStream.OnNext(e.Data); process.ErrorDataReceived += (sender, e) => _outputErrorStream.OnNext(e.Data); process.Start(); _outputDataStream.OnNext("Capture service started..."); process.BeginOutputReadLine(); process.BeginErrorReadLine(); _logger.LogInformation("PresentMon successfully started"); return(true); } catch (Exception e) { _logger.LogError(e, "Failed to Start CaptureService"); return(false); } }
public IntervalService(IServiceStartInfo startInfo) : base(startInfo) { this.InnerProcess = CreateProcess(); }
public LaunchService(IServiceStartInfo startInfo) : base(startInfo) { this.InnerProcess = CreateProcess(); }
public bool StartCaptureService(IServiceStartInfo startInfo) { return(_presentMonCaptureService.StartCaptureService(startInfo)); }