Browse Source

Fixed DiscordClient.Disconnect stalling

pull/57/head
RogueException 9 years ago
parent
commit
f04789619a
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      src/Discord.Net/DiscordClient.cs

+ 7
- 5
src/Discord.Net/DiscordClient.cs View File

@@ -1078,19 +1078,21 @@ namespace Discord
const short batchSize = 50;
ulong[] serverIds = new ulong[batchSize];

while (true)
while (!cancelToken.IsCancellationRequested && State == ConnectionState.Connecting)
await Task.Delay(100).ConfigureAwait(false);

while (!cancelToken.IsCancellationRequested && State == ConnectionState.Connected)
{
if (!cancelToken.IsCancellationRequested && State == ConnectionState.Connected)
if (_largeServers.Count > 0)
{
int count = 0;

while (count < batchSize && _largeServers.TryDequeue(out serverIds[count]))
count++;

if (count > 0 && !cancelToken.IsCancellationRequested)
if (count > 0)
GatewaySocket.SendRequestMembers(serverIds.Take(count), "", 0);
}
await Task.Delay(1250);
await Task.Delay(1250).ConfigureAwait(false);
}
}
catch (OperationCanceledException) { }


Loading…
Cancel
Save