示例#1
0
        public async Task Handle(RollTheDice message)
        {
            logger.LogDebug($"Rolling the dice {message.Attempts} times");

            var sw = new Stopwatch();

            sw.Start();
            for (var i = 0; i < message.Attempts; i++)
            {
                var result = new Random().Next(1, 7);
                await publisher.Publish(new DiceRolled { Result = result });

                logger.LogInformation($"Result published {message.Order}");
            }
            sw.Stop();

            logger.LogInformation($"{message.Attempts} times took ${sw.Elapsed.TotalSeconds} s");

            await my.DoSomeWork();
        }
示例#2
0
 public Task Handle(RollTheDice message)
 {
     return(myClass.DoSomeWork());
 }