Skip to content

Commit

Permalink
Fix threadsafe poll events (fix #131)
Browse files Browse the repository at this point in the history
  • Loading branch information
RevenantX committed Jan 12, 2018
1 parent 949cf67 commit 10ec7d7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions LiteNetLib/NetManager.cs
Expand Up @@ -910,13 +910,15 @@ public void PollEvents()
{
if (UnsyncedEvents)
return;

while (_netEventsQueue.Count > 0)
while (true)
{
NetEvent evt;
lock (_netEventsQueue)
{
evt = _netEventsQueue.Dequeue();
if (_netEventsQueue.Count > 0)
evt = _netEventsQueue.Dequeue();
else
return;
}
ProcessEvent(evt);
}
Expand Down

0 comments on commit 10ec7d7

Please sign in to comment.