From 452fdd3b4cd96768777b04e3621732b69a1b1062 Mon Sep 17 00:00:00 2001 From: Thinh Buzz Date: Fri, 6 Jun 2025 13:27:51 +0700 Subject: [PATCH] Make schedule method asynchronous to handle Promise callbacks --- lib/structs/thread.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/structs/thread.ts b/lib/structs/thread.ts index b7c58be..b2f7cbe 100644 --- a/lib/structs/thread.ts +++ b/lib/structs/thread.ts @@ -81,14 +81,14 @@ namespace Il2Cpp { } /** Schedules a callback on the current thread. */ - schedule(block: () => T): Promise { + async schedule(block: () => T | Promise): Promise { const Post = this.synchronizationContext?.tryMethod("Post"); if (Post == null) { - return Process.runOnThread(this.id, block); + return await Process.runOnThread>(this.id, block); } - return new Promise(resolve => { + return await new Promise(resolve => { const delegate = Il2Cpp.delegate(Il2Cpp.corlib.class("System.Threading.SendOrPostCallback"), () => { const result = block(); setImmediate(() => resolve(result));