Browse Source

Fixed dispatcher for macOS

pull/10691/head
Nikita Tsukanov 3 years ago
parent
commit
ee445f2197
  1. 4
      native/Avalonia.Native/src/OSX/platformthreading.mm
  2. 8
      src/Avalonia.Base/Threading/Dispatcher.Queue.cs

4
native/Avalonia.Native/src/OSX/platformthreading.mm

@ -79,13 +79,11 @@ static double distantFutureInterval = (double)50*365*24*3600;
bool signaled;
@synchronized (self) {
signaled = self->_signaled;
self->_signaled = false;
}
if(signaled)
{
self->_events->Signaled();
@synchronized (self) {
self->_signaled = false;
}
}
});
CFRunLoopAddObserver(CFRunLoopGetMain(), _observer, kCFRunLoopCommonModes);

8
src/Avalonia.Base/Threading/Dispatcher.Queue.cs

@ -124,7 +124,13 @@ public partial class Dispatcher
else if (_pendingInputImpl?.CanQueryPendingInput == true)
{
if (!_pendingInputImpl.HasPendingInput)
ExecuteJob(job);
{
// On platforms like macOS HasPendingInput check might trigger a timer
// which would result in reentrancy here, so we check if the job
// hasn't been executed yet
if (job.Status == DispatcherOperationStatus.Pending)
ExecuteJob(job);
}
else
{
RequestBackgroundProcessing();

Loading…
Cancel
Save