Example #1
0
        private Task Start(IKernel kernel, TaskScheduler scheduler, CancellationToken token)
        {
            if (_servers.Length == 0)
            {
                return(Task.FromResult(true));
            }

            var server = new BackgroundWorkerServer(this, scheduler);

            Task task = server.Create(new BackgroundServerContext(kernel), token);

            return(task);
        }
Example #2
0
        private BackgroundServerHost CreateHeartbeatLoggingServerHost(InternalConfiguration configuration, TaskScheduler scheduler, IKernel kernel)
        {
            TimeSpan?interval = configuration.HeartbeatLoggingInterval;

            if (interval.HasValue)
            {
                IHeartbeatProvider[] providers = kernel
                                                 .ResolveAll <IHeartbeatProvider>()
                                                 .Prepend(this)
                                                 .ToArray();

                var repository = kernel.Resolve <IHeartbeatLoggingRepository>();

                var worker = new HeartbeatLoggingWorker(providers, interval.Value, repository);
                var server = new BackgroundWorkerServer(worker, scheduler);

                var host = new BackgroundServerHost(server, scheduler, kernel, _output, _cancellation.Token);

                return(host);
            }

            return(null);
        }