Fixed crash

This commit is contained in:
Kwoth 2016-10-24 23:36:03 +02:00
parent 8b3a438e34
commit cf0f0be84f

View File

@ -48,15 +48,21 @@ namespace NadekoBot.Modules.Administration
t = new Timer(async (state) => t = new Timer(async (state) =>
{ {
var keys = UserPresenceUpdates.Keys.ToList(); try
await Task.WhenAll(keys.Select(key =>
{ {
List<string> messages; var keys = UserPresenceUpdates.Keys.ToList();
if (UserPresenceUpdates.TryRemove(key, out messages))
try { return key.SendMessageAsync(string.Join(Environment.NewLine, messages)); } catch { } //502/403 await Task.WhenAll(keys.Select(async key =>
return Task.CompletedTask; {
})); List<string> messages;
if (UserPresenceUpdates.TryRemove(key, out messages))
try { await key.SendMessageAsync(string.Join(Environment.NewLine, messages)); } catch { }
}));
}
catch (Exception ex)
{
_log.Warn(ex);
}
}, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10)); }, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10));