Skip to content

Commit ba50d00

Browse files
leszekm1mattqs
authored andcommitted
destroy all subs in cleanup (#113)
1 parent 7bf8259 commit ba50d00

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

Src/SocketIoClientDotNet.net45/Client/Manager.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,11 @@ private void ProcessPacketQueue()
395395

396396
private void Cleanup()
397397
{
398-
// Concurrent-queue makes a copy when calling GetEnumerator
399-
// which protects it from any changes done in Subs while calling destroy
400-
foreach (var sub in Subs)
398+
// dequeue and destroy until empty
399+
while (Subs.TryDequeue(out On.IHandle sub))
401400
{
402401
sub.Destroy();
403402
}
404-
405-
// dequeue until empty (ConcurrentQueue does not have a Clear() method)
406-
On.IHandle tmp;
407-
while (Subs.TryDequeue(out tmp));
408403
}
409404

410405
public void Close()

0 commit comments

Comments
 (0)