diff --git a/src/lime/_internal/backend/native/NativeApplication.hx b/src/lime/_internal/backend/native/NativeApplication.hx index ad45bbaba0..f7ec48e46d 100644 --- a/src/lime/_internal/backend/native/NativeApplication.hx +++ b/src/lime/_internal/backend/native/NativeApplication.hx @@ -695,7 +695,11 @@ class NativeApplication } #if (haxe_ver >= 4.2) #if target.threaded + #if haxe5 + sys.thread.Thread.current().events.loopOnce(); + #else sys.thread.Thread.current().events.progress(); + #end #else // Duplicate code required because Haxe 3 can't handle // #if (haxe_ver >= 4.2 && target.threaded) diff --git a/src/lime/app/Promise.hx b/src/lime/app/Promise.hx index 96b59fdc7e..fa3b095be8 100644 --- a/src/lime/app/Promise.hx +++ b/src/lime/app/Promise.hx @@ -105,7 +105,11 @@ class Promise { if (!ThreadPool.isMainThread()) { + #if haxe5 + haxe.EventLoop.main.run(complete.bind(data)); + #else haxe.MainLoop.runInMainThread(complete.bind(data)); + #end return this; } @@ -197,7 +201,11 @@ class Promise { if (!ThreadPool.isMainThread()) { + #if haxe5 + haxe.EventLoop.main.run(error.bind(msg)); + #else haxe.MainLoop.runInMainThread(error.bind(msg)); + #end return this; } @@ -236,7 +244,11 @@ class Promise { if (!ThreadPool.isMainThread()) { + #if haxe5 + haxe.EventLoop.main.run(this.progress.bind(progress, total)); + #else haxe.MainLoop.runInMainThread(this.progress.bind(progress, total)); + #end return this; } diff --git a/src/lime/system/JNI.hx b/src/lime/system/JNI.hx index ed2007028b..884ad72013 100644 --- a/src/lime/system/JNI.hx +++ b/src/lime/system/JNI.hx @@ -459,8 +459,16 @@ class JNISafetyTools } // Check the thread before running the function. - f.expr = macro if (!lime.system.JNI.JNISafetyTools.onMainThread()) haxe.MainLoop.runInMainThread($i{field.name}.bind($a{args})) else - ${f.expr}; + f.expr = macro + if (!lime.system.JNI.JNISafetyTools.onMainThread()) { + #if haxe5 + haxe.EventLoop.main.run($i{field.name}.bind($a{args})); + #else + haxe.MainLoop.runInMainThread($i{field.name}.bind($a{args})); + #end + } else { + ${f.expr}; + }; default: } }