Currently available on .NET only and coming to all platforms in Elements 8.3, the __await expression construct can be used to "unwrap" otherwise asynchronous code so that future results can be dealt with in a linear fashion.

Under the hood, __await will break the method into different parts, scheduling them to be executed asynchronously once the awaited actions have been completed.

import System.Threading
import System.Threading.Tasks

func test() -> Task<String> {

    let task = Task<String>() {
        return "Result!"
    return task


func OtherMethod() {
  println(__await test())
  println("after test")

At the point of the __await in OtherMethod, the actual method containing the __await will return, returning the future.

If a method using __await has a return type, it must be a Task<T>.


.NET Only

  • __await is currently available on the .NET platform only.

See Also

  • await keyword in Oxygene