write to console on run

This commit is contained in:
Matt Parker
2025-08-25 18:53:24 +10:00
parent feffc0d7a8
commit 31884214bc
4 changed files with 61 additions and 4 deletions

View File

@@ -43,4 +43,37 @@ public static class NodeExtensions
}).CallDeferred();
return taskCompletionSource.Task;
}
}
public static class GodotTask
{
public static async Task Run(Action action)
{
await Task.Run(() =>
{
try
{
action();
}
catch (Exception ex)
{
GD.PrintErr($"Error: {ex}");
}
});
}
public static async Task Run(Func<Task> action)
{
await Task.Run(async () =>
{
try
{
await action();
}
catch (Exception ex)
{
GD.PrintErr($"Error: {ex}");
}
});
}
}