For those curious, this code snippet is what helped me solve this, from "youwin"
The thread.wait_to_finish()
returns the return value of the thread.
extends Node2D
var thread: Thread
func _ready() -> void:
thread = Thread.new()
thread.start(self, "_thread")
while thread.is_alive():
yield(get_tree(), "idle_frame")
print(thread.wait_to_finish())
thread = null
func _thread() -> String:
var output := []
var err: int = OS.execute("CMD.exe", ["/C", "dir"], true, output)
if err != 0:
printerr("Error occurred: %d" % err)
return PoolStringArray(output).join("\n")