コード例 #1
0
        private static async Task SendNotifications()
        {
            var testNotification = new ApplyDiscountNotification
            {
                RecipeName     = "recipe1",
                IngredientType = IngredientType.AcidRegulator,
                Total          = 10
            };

            var notifications = Enumerable.Repeat(testNotification, 10);
            await Task.WhenAll(notifications.Select(ProcessNotificationsAsync)).ConfigureAwait(false);
        }
コード例 #2
0
 private static async Task ProcessNotificationsAsync(ApplyDiscountNotification notification)
 {
     using var scope = serviceProvider.CreateScope();
     var mediator = scope.ServiceProvider.GetRequiredService <IMediator>();
     await mediator.Publish(notification).ConfigureAwait(false);
 }