Browse Source

Fix main loop cancellation from another thread

pull/12579/head
Hanjiang Yu 3 years ago
parent
commit
f895661879
  1. 29
      native/Avalonia.Native/src/OSX/platformthreading.mm

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

@ -17,7 +17,6 @@ public:
Cancelled = true; Cancelled = true;
if(Running) if(Running)
{ {
Running = false;
if(![NSThread isMainThread]) if(![NSThread isMainThread])
{ {
AddRef(); AddRef();
@ -28,22 +27,22 @@ public:
}); });
return; return;
}; };
Running = false;
if(IsApp) if(IsApp)
[NSApp stop:nil]; [NSApp stop:nil];
else
{ // Wakeup the event loop
// Wakeup the event loop NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined location:NSMakePoint(0, 0)
location:NSMakePoint(0, 0) modifierFlags:0
modifierFlags:0 timestamp:0
timestamp:0 windowNumber:0
windowNumber:0 context:nil
context:nil subtype:0
subtype:0 data1:0
data1:0 data2:0];
data2:0]; [NSApp postEvent:event atStart:YES];
[NSApp postEvent:event atStart:YES];
}
} }
}; };
}; };

Loading…
Cancel
Save