Browse Source

Merge pull request #4691 from AvaloniaUI/fixes/linux-render-timer-hard-loop

Fixed SleepLoopRenderTimer
pull/4694/head
danwalmsley 6 years ago
committed by GitHub
parent
commit
5e46f03cf2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/Avalonia.Visuals/Rendering/SleepLoopRenderTimer.cs

9
src/Avalonia.Visuals/Rendering/SleepLoopRenderTimer.cs

@ -45,14 +45,13 @@ namespace Avalonia.Rendering
void LoopProc()
{
var now = _st.Elapsed;
var lastTick = now;
var lastTick = _st.Elapsed;
while (true)
{
var now = _st.Elapsed;
var timeTillNextTick = lastTick + _timeBetweenTicks - now;
if (timeTillNextTick.TotalMilliseconds > 1) Thread.Sleep(timeTillNextTick);
lastTick = now;
lock (_lock)
{
if (_count == 0)
@ -63,7 +62,7 @@ namespace Avalonia.Rendering
}
_tick?.Invoke(now);
now = _st.Elapsed;
}
}

Loading…
Cancel
Save