optimize TwilioMessageQueueService.cs
optimize TwilioMessageQueueService.cs
This commit is contained in:
parent
b77fb87a5e
commit
e9194b8247
|
|
@ -28,19 +28,22 @@ namespace BotSharp.Plugin.Twilio.Services
|
|||
await foreach (var message in _queue.Reader.ReadAllAsync(stoppingToken))
|
||||
{
|
||||
await _throttler.WaitAsync(stoppingToken);
|
||||
try
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
Console.WriteLine($"Start processing {message}.");
|
||||
await ProcessUserMessageAsync(message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Processing {message} failed due to {ex.Message}.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_throttler.Release();
|
||||
}
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"Start processing {message}.");
|
||||
await ProcessUserMessageAsync(message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Processing {message} failed due to {ex.Message}.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_throttler.Release();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue