Using the await operator with Lua

I'm using NLua and I'm having trouble with one of my methods that I'm registering. It's a method that returns a Task of bool and it's async, meaning I have to include the await operator before it. However, I'm getting a syntax error when I include it inside my Lua script.

How is it possible to include the await operator inside a Lua script?

EDIT: My goal is to make a method that halts it's execution until a response has been set, and then returns the response's result. I believe this has to be done with Tasks, but I'm not sure how to do this.

My old code was:

   public async Task<bool> SomeMethod()
    {
        this.Response = new TaskCompletionSource<bool>();

        return await this.Response.Task;
    }

And then, I would just set Response's Result. However, now that I don't have the await operator anymore, I'm not sure ho wto do this. The scripts don't run on a different thread. I want to be able to stop the execution without halting the main thread.

Jon Skeet
people
quotationmark

It's a method that returns a Task of bool and it's async, meaning I have to include the await operator before it.

You don't have to use await with methods returning tasks - that's just a feature of C# which makes it easier to write asynchronous code. If NLua doesn't have a similar feature, you'll have to make do without it, e.g. by adding continuations to the task with the Task.ContinueWith method. It's important to understand that await is primarily a language feature in C# and VB... it's not part of the framework in itself.

people

See more on this question at Stackoverflow