public BackgroundServerHost(IBackgroundServer server, TaskScheduler scheduler, IKernel kernel, Action <string> output, CancellationToken?token = null) { if (server == null) { throw new ArgumentNullException(nameof(server)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } if (kernel == null) { throw new ArgumentNullException(nameof(kernel)); } if (output == null) { throw new ArgumentNullException(nameof(output)); } _server = server; _scheduler = scheduler; _token = token.GetValueOrDefault(kernel.Resolve <IShutdown>().Token); _output = message => output($"[{this}]: {message}"); _context = new RestartableContext(kernel); _uptime = kernel.Resolve <IUptimeTextGenerator>(); }
public bool ShouldRestart(RestartableContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var restartable = _worker as IRestartable; return(restartable != null && restartable.ShouldRestart(context)); }