mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Implement dynamic sleep time (#1459)
* Dynamic sleep time * Small code refactor in dynamic sleep time Co-authored-by: ORelio <ORelio@users.noreply.github.com>
This commit is contained in:
parent
71eb1dca17
commit
9d41e2223d
1 changed files with 10 additions and 3 deletions
|
|
@ -151,11 +151,18 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
do
|
bool keepUpdating = true;
|
||||||
|
Stopwatch stopWatch = new Stopwatch();
|
||||||
|
while (keepUpdating)
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
stopWatch.Start();
|
||||||
|
keepUpdating = Update();
|
||||||
|
stopWatch.Stop();
|
||||||
|
int elapsed = stopWatch.Elapsed.Milliseconds;
|
||||||
|
stopWatch.Reset();
|
||||||
|
if (elapsed < 100)
|
||||||
|
Thread.Sleep(100 - elapsed);
|
||||||
}
|
}
|
||||||
while (Update());
|
|
||||||
}
|
}
|
||||||
catch (System.IO.IOException) { }
|
catch (System.IO.IOException) { }
|
||||||
catch (SocketException) { }
|
catch (SocketException) { }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue