public ControlManager( INLogger logger, IProcessClient processClient, IWin32APIClient win32APIClient) { this.Logger = logger; this.ProcessClient = processClient; this.Win32APIClient = win32APIClient; }
public DeviceHub(IProcessClient processClient, ConnectionMapping connectionMapping, IProcessInfoProvider processInfoProvider, ClientTaskFactory clientTaskFactory, IProcessHandlersFactory processHandlersFactory) { _processClient = processClient; _connectionMapping = connectionMapping; _processInfoProvider = processInfoProvider; _clientTaskFactory = clientTaskFactory; _processHandlersFactory = processHandlersFactory; }
public CommandFactory( IWcfClient wcfClient, IProcessClient processClient, IConfigProvider configProvider, IMessageSender messageSender, ITPLFactory tPLFactory) { this.wcfClient = wcfClient; this.processClient = processClient; this.configProvider = configProvider; this.messageSender = messageSender; this.tPLFactory = tPLFactory; }
public void ClientDisconnected(IProcessClient processClient, Process process) { Console.WriteLine("Client disconnected, cleaning up pid {0}", process.Id); // once the client has disconnected, kill its corresponding process try { process.Kill(); } catch (System.Exception) { // we can get in here if the process has already exited } }
private void ReadStdErr(IProcessClient processClient, Process process) { try { string str; while ((str = process.StandardError.ReadLine()) != null) { processClient.ProcessOutputReceived(str); Thread.Sleep(mReadThreadSleepTime); } } catch (System.Exception) { // if we get an exception, the client has disconnected, so kill the process ClientDisconnected(processClient, process); } }
private void WaitForExit(IProcessClient processClient, Process process) { try { // wait for the process to exit and make sure all the process output is sent while (!process.HasExited || !process.StandardOutput.EndOfStream || !process.StandardError.EndOfStream) { // ping the client. if this fails, an exception will be thrown processClient.Ping(); Thread.Sleep(mExitThreadSleepTime); } processClient.ProcessExited(process.ExitCode); } catch (System.Exception) { // if we get an exception, the client has disconnected, so kill the process ClientDisconnected(processClient, process); } }
public int RunProcess(IProcessClient client, string fileName, string arguments, string workingDirectory, bool fork) { Console.WriteLine(String.Format("Running file: {0} args: {1} dir: {2} fork: {3}", fileName, arguments, workingDirectory, fork)); // take the start info and fire off a process. Just let it do its thing. Process process = new Process(); process.StartInfo.FileName = fileName; process.StartInfo.Arguments = arguments; process.StartInfo.WorkingDirectory = workingDirectory; if (!fork) { process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.CreateNoWindow = true; } try { process.Start(); // if they want to fork, fire and forget if (!fork) { new ProcessDelegate(ReadStdOut).BeginInvoke(client, process, null, null); new ProcessDelegate(ReadStdErr).BeginInvoke(client, process, null, null); new ProcessDelegate(WaitForExit).BeginInvoke(client, process, null, null); } return(process.Id); } catch (System.Exception) { return(0); } }
public ClientTaskFactory(IProcessHandlersFactory processHandlersFactory, IProcessClient processClient) { _processHandlersFactory = processHandlersFactory; _processClient = processClient; }
public PickersHub(IPickerRepository pickerRepository, IProcessClient processClient, ITaskRepository taskRepository) { _pickerRepository = pickerRepository; _processClient = processClient; _taskRepository = taskRepository; }
public AssignTaskHandler(IPickerRepository pickerRepository, ITaskRepository taskRepository, IProcessClient processClient) { _pickerRepository = pickerRepository; _taskRepository = taskRepository; }