public Task <MessageResult> TryStart(SimpleProcessInfo info) { var simpleProcessFactory = SimpleProcessFactory.Resolve(); var simpleProcess = simpleProcessFactory.GetOrCreate(info); var simpleProcessRunner = new SimpleProcessRunner(simpleProcess); if (_fooClientDaemon == null) { var simpleDaemon = SimpleDaemon.Resolve(); _fooClientDaemon = new FooClientDaemon(simpleDaemon, simpleProcessRunner); } else { if (!info.ProcessName.Equals(_fooClientDaemon.Runner.Process.Info.ProcessName, StringComparison.OrdinalIgnoreCase)) { _fooClientDaemon.Daemon.Dispose(); _fooClientDaemon.Daemon = null; var simpleDaemon = SimpleDaemon.Resolve(); _fooClientDaemon = new FooClientDaemon(simpleDaemon, simpleProcessRunner); } } return(_fooClientDaemon.TryStart()); }
private void MyInitializeComponent() { this.ServiceName = "FooClientDaemon"; var simpleProcessFactory = SimpleProcessFactory.Resolve(); var fooClientInfo = new SimpleProcessInfo() { ProcessName = "FooClient", ExePath = "FooClient.exe", ExeArgs = "" }; simpleProcessFactory.GetOrCreate(fooClientInfo); Daemon = SimpleDaemon.Resolve(); }