Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async / await support #228

Open
badevilerror opened this issue Jun 5, 2018 · 0 comments
Open

Async / await support #228

badevilerror opened this issue Jun 5, 2018 · 0 comments

Comments

@badevilerror
Copy link

I'm unable to make my Lua / MoonSharp code to work with C# async / await.

What i've tried is basically:

async void Test1() {
   await SomethingAsync();
}

async Task Test2() {
   await SomethingAsync();
}

When calling those methods from Lua - async void has no effect, script just go on, without awaiting; and async Task throws an exception: ScriptRuntimeException: cannot convert clr type System.Threading.Tasks.Task`1[System.Threading.Tasks.VoidTaskResult] MoonSharp.Interpreter.Interop.Converters.ClrToScriptConversions.ObjectToDynValue

For the time being i'm using callbacks as a workaround, but i don't feel that's a good solution. For example using a C# async method with a callback makes the whole Lua script an async one - now also C# method is not awaiting.

As far as i can see there's also Function.CallAsync() but it's not working for me, as Unity is throwing exceptions about using it's apis from different threads.

Dunno, maybe it's me being stupid, but i don't know how to make it work.

I've also made a question on SO but it looks like nobody knows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant