Пример #1
0
 public FibonacciNumberMessage Build(FibonacciNumber number)
 {
     return(new FibonacciNumberMessage
            (
                id: guidManager.GetNew(),
                createdAt: dateTimeManager.GetNow(),
                data: new FibonacciNumber
                (
                    index: number.Index,
                    value: number.Value
                )
            ));
 }
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            logger.LogInformation("Start worker");

            var subscribingResults = Enumerable
                                     .Range(0, workerConfig.ComputedSequencesCount)
                                     .Select(_ => guidManager.GetNew())
                                     .Select(fibonacciComputingRunner.RunComputing)
                                     .ToArray();

            stoppingToken.WaitHandle.WaitOne();
            logger.LogInformation("Cancellation has been requested");

            subscribingResults.ForEach(x => x.Dispose());
            logger.LogInformation("All subscriptions are canceled");

            return(Task.FromResult(0));
        }