public Task Handle(DemoNotification notification)
        {
            var msg = $"Handled in {this.GetType().Name} (Thread {Thread.CurrentThread.ManagedThreadId}) - {notification.Message})";

            _messageSource.Add(msg);
            return(Task.CompletedTask);
        }
Esempio n. 2
0
        public Task <bool> Handle(DemoRequest message)
        {
            var msg = $"Handled in {this.GetType().Name} (Thread {Thread.CurrentThread.ManagedThreadId}) - {message.Message})";

            _messageSource.Add(msg);
            return(Task.FromResult(true));
        }
Esempio n. 3
0
        public Task Handle(BaseAsyncAppEvent notification)
        {
            Thread.Sleep(3000);

            var msg = $"Handled in {this.GetType().Name} (Thread {Thread.CurrentThread.ManagedThreadId}) - {notification.Message})";

            _messageSource.Add(msg);
            return(Task.CompletedTask);
        }
        public async Task <IActionResult> PublishAsyncEvent()
        {
            var notification = new DemoAsyncNotification()
            {
                Message = $"event published on {DateTime.Now} in {this.GetType().Name} (Thread {Thread.CurrentThread.ManagedThreadId})"
            };

            Task.Run(() => {
                try
                {
                    _mediator.PublishAsync(notification);
                }
                catch (Exception ex)
                {
                    _messageSource.Add($"exception caught in {this.GetType().Name} (Thread {Thread.CurrentThread.ManagedThreadId}): {ex.Message}");
                }
            });
            return(RedirectToAction("Index"));
        }
        public Task Handle(DemoAsyncNotification notification)
        {
            Thread.Sleep(2000);
            throw new Exception($"Error thrown in {this.GetType().Name} (Thread {Thread.CurrentThread.ManagedThreadId})");

            var msg = $"Handled in {this.GetType().Name} (Thread {Thread.CurrentThread.ManagedThreadId}) - {notification.Message})";

            _messageSource.Add(msg);
            return(Task.CompletedTask);
        }
Esempio n. 6
0
 public void Handle(Exception ex)
 {
     _messageSource.Add($"Exception handled in {this.GetType().Name} (Thread {Thread.CurrentThread.ManagedThreadId})");
 }