protected override async Task ExecuteAsync(CancellationToken stoppingToken) { _consumerService.Consume(); while (!stoppingToken.IsCancellationRequested) { Console.WriteLine("executing background loop"); await Task.Delay(TimeSpan.FromSeconds(2), stoppingToken); } }
public void WaitForBotResponse() { _consumerService.Consume <ChatMessage> ( Constants.BOT_USERS_QUEUE, async botMessage => { /* It wasnt clear in the docs if I should save in the database the response for the command * So, As the request command isn`t being saved, I didnt save the response */ await _hubContext.Clients.All.SendAsync("receive", botMessage); } ); }