wait
- Last UpdatedApr 24, 2024
- 1 minute read
The wait operator can only be used in async methods. Wait operator suspends evaluation of the enclosing async method until its condition is verified. After that, the control returns to the caller of the method.
Wait condition must not be blocking.
Example code
class TestWait
{
public static int waitValue;
public static bool waitVar()
{
return waitValue==0;
}
public async static void test()
{
Runtime::Environment.Print("--wait started”);
wait(waitVar()); //wait until waitValue value changes
Runtime::Environment.Print("--wait ended”);
}
}