Browse Source

Fixed ManagedDispatcherImpl wait

pull/11596/head
Julien Lebosquain 3 years ago
parent
commit
fb9baae012
No known key found for this signature in database GPG Key ID: 1833CAD10ACC46FD
  1. 12
      src/Avalonia.Controls/Platform/ManagedDispatcherImpl.cs

12
src/Avalonia.Controls/Platform/ManagedDispatcherImpl.cs

@ -99,9 +99,15 @@ public class ManagedDispatcherImpl : IControlledDispatcherImpl
continue; continue;
} }
if (_nextTimer != null) TimeSpan? nextTimer;
lock (_lock)
{
nextTimer = _nextTimer;
}
if (nextTimer != null)
{ {
var waitFor = _clock.Elapsed - _nextTimer.Value; var waitFor = nextTimer.Value - _clock.Elapsed;
if (waitFor.TotalMilliseconds < 1) if (waitFor.TotalMilliseconds < 1)
continue; continue;
_wakeup.WaitOne(waitFor); _wakeup.WaitOne(waitFor);
@ -112,4 +118,4 @@ public class ManagedDispatcherImpl : IControlledDispatcherImpl
registration.Dispose(); registration.Dispose();
} }
} }

Loading…
Cancel
Save