示例#1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                IEventArgs workItem =
                    await _queue.DequeueAsync(stoppingToken);

                if (workItem != null)
                {
                    switch (workItem.GetType().Name)
                    {
                    case nameof(RandomEventArgs):
                        var result = await _mediator.Send(new GetRandomNumberCommand(), stoppingToken);

                        if (result.IsSuccess)
                        {
                            _logger.LogInformation($"{workItem.RequestDateTime.ToLocalTime()} : {result.Value}");
                        }
                        else
                        {
                            _logger.LogError(result.Error);
                        }
                        break;

                    default:
                        _logger.LogError($"Unhandled Event Type {workItem.GetType().Name}");
                        break;
                    }
                }
            }
        }
示例#2
0
文件: AnyArgs.cs 项目: s1gurd/W-Hub
 public Type GetInnerType()
 {
     return(innerArgs.GetType());
 }