mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-21 21:54:36 +00:00
Slightly improve birthday update task handling
This commit is contained in:
parent
670309715b
commit
c5cab92899
1 changed files with 11 additions and 11 deletions
|
@ -25,25 +25,25 @@ namespace BirthdayBot.BackgroundServices
|
||||||
var tasks = new List<Task>();
|
var tasks = new List<Task>();
|
||||||
foreach (var guild in BotInstance.DiscordClient.Guilds)
|
foreach (var guild in BotInstance.DiscordClient.Guilds)
|
||||||
{
|
{
|
||||||
var t = ProcessGuildAsync(guild);
|
tasks.Add(ProcessGuildAsync(guild));
|
||||||
tasks.Add(t);
|
|
||||||
}
|
}
|
||||||
|
var alltasks = Task.WhenAll(tasks);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await Task.WhenAll(tasks);
|
await alltasks;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// TODO does this not actually work as might be expected?
|
var exs = alltasks.Exception;
|
||||||
var exs = from task in tasks
|
if (exs != null)
|
||||||
where task.Exception != null
|
|
||||||
select task.Exception;
|
|
||||||
Log($"Encountered {exs.Count()} errors during bulk guild processing.");
|
|
||||||
foreach (var iex in exs)
|
|
||||||
{
|
{
|
||||||
// TODO probably not a good idea
|
Log($"{exs.InnerExceptions.Count} exception(s) during bulk processing!");
|
||||||
Log(iex.ToString());
|
// TODO needs major improvements. output to file?
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log(ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue