mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Trim
This commit is contained in:
parent
0382e07d50
commit
3b95cbcce0
1 changed files with 5 additions and 10 deletions
|
|
@ -195,30 +195,25 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
cancelToken.ThrowIfCancellationRequested();
|
cancelToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
handler.OnUpdate();
|
handler.OnUpdate();
|
||||||
|
stopWatch.Restart();
|
||||||
|
|
||||||
stopWatch.Start();
|
|
||||||
while (packetQueue.TryTake(out Tuple<int, Queue<byte>>? packetInfo))
|
while (packetQueue.TryTake(out Tuple<int, Queue<byte>>? packetInfo))
|
||||||
{
|
{
|
||||||
(int packetID, Queue<byte> packetData) = packetInfo;
|
(int packetID, Queue<byte> packetData) = packetInfo;
|
||||||
HandlePacket(packetID, packetData);
|
HandlePacket(packetID, packetData);
|
||||||
|
|
||||||
stopWatch.Stop();
|
|
||||||
if (stopWatch.Elapsed.Milliseconds >= 100)
|
if (stopWatch.Elapsed.Milliseconds >= 100)
|
||||||
{
|
{
|
||||||
stopWatch.Reset();
|
|
||||||
handler.OnUpdate();
|
handler.OnUpdate();
|
||||||
|
stopWatch.Restart();
|
||||||
}
|
}
|
||||||
stopWatch.Start();
|
|
||||||
}
|
}
|
||||||
stopWatch.Stop();
|
|
||||||
|
|
||||||
if (stopWatch.Elapsed.Milliseconds < 100)
|
int sleepLength = 100 - stopWatch.Elapsed.Milliseconds;
|
||||||
Thread.Sleep(100 - stopWatch.Elapsed.Milliseconds);
|
if (sleepLength > 0)
|
||||||
stopWatch.Reset();
|
Thread.Sleep(sleepLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (System.IO.IOException) { }
|
|
||||||
catch (SocketException) { }
|
|
||||||
catch (ObjectDisposedException) { }
|
catch (ObjectDisposedException) { }
|
||||||
catch (OperationCanceledException) { }
|
catch (OperationCanceledException) { }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue