Skip to content

Commit

Permalink
destroy all subs in cleanup (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
leszekm1 authored and mattqs committed Aug 24, 2017
1 parent 7bf8259 commit ba50d00
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions Src/SocketIoClientDotNet.net45/Client/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,11 @@ private void ProcessPacketQueue()

private void Cleanup()
{
// Concurrent-queue makes a copy when calling GetEnumerator
// which protects it from any changes done in Subs while calling destroy
foreach (var sub in Subs)
// dequeue and destroy until empty
while (Subs.TryDequeue(out On.IHandle sub))
{
sub.Destroy();
}

// dequeue until empty (ConcurrentQueue does not have a Clear() method)
On.IHandle tmp;
while (Subs.TryDequeue(out tmp));
}

public void Close()
Expand Down

0 comments on commit ba50d00

Please sign in to comment.