解決方法:
コードを修正して、AWAIT 式を ASYNC メソッド内に配置します。
例:
以下の例で、SYNC ブロック内で誤って使用された AWAIT 式、および ASYNC メソッド内で正しく使用された AWAIT 式を示します。
$set ilusing"System"
$set ilusing "System.Threading.Tasks"
$set sourceformat(variable)
class-id A.
method-id Main static.
*> Demo 1
invoke type Console::WriteLine("Awaiting call to long operation:");
declare withAwaitAtCallTask = WithAwaitAtCallAsync()
invoke withAwaitAtCallTask::Wait()
end method.
method-id WithAwaitAtCallAsync() private static async.
declare o as object = "Hello"
sync on o
invoke await type Task::Delay(1000);
end-sync
end method.
end class.