diff --git a/src/lime/_internal/backend/native/NativeApplication.hx b/src/lime/_internal/backend/native/NativeApplication.hx index a6478bba2d..2eaa5d0cbd 100644 --- a/src/lime/_internal/backend/native/NativeApplication.hx +++ b/src/lime/_internal/backend/native/NativeApplication.hx @@ -692,7 +692,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 8c1c4ad5bd..2d53634b71 100644 --- a/src/lime/system/JNI.hx +++ b/src/lime/system/JNI.hx @@ -466,9 +466,13 @@ 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 + 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: }