The thread keyword is not working in the way that using Sleep() inside a function stops execution there instead of delaying it for a later frame. It does work in the Workbench though. So there appears to be a difference between the script-vm build of workbench and release executables.
I have run this code in different places, via thread ThreadTest(); and GetGame().GetScriptModule().Call(this, "ThreadTest", true, null);
void ThreadTest() { Print("ThreadTest #1"); Sleep(100); Print("ThreadTest #2"); }
Both lead to the same result. The first print shows, but the second does not - in the workbench both show as they should.
I know this keyword is not used in vanilla AR, so this might appear as an unimportant bug, but it is a core essential for my use case that has no alternatives.
I have several operations that are async that I need to await without starting to get into callback hell. So I wanted to group them in one threaded function that can wait for results by using Sleep and see if the results are ready. Without this, I need to split my function into many many sub-functions that call each other when one finishes, making it borderline impossible to write readable code.