I've got a simple function in Delphi that is marked as an [async]
function.
Currently, the function doesn't do anything. It literally just returns a Boolean
value of True
:
[async]
function MyAsyncFunction(): Boolean;
implementation
function MyAsyncFunction(): Boolean;
begin
Result := True;
end;
But then every time I try to use the function like:
if MyAsyncFunction then
begin
// Do Stuff
end;
then I get the following error:
[Error] Boolean expected, but Context found
What is Context
and what is the correct way to call an async
function in TMS WEB Core using Delphi?
@DalikaPrasnikar gave a great link in the comments regarding async
in TMS WEB Core.
Turns out that I simply had to wrap my call to MyAsyncFunction
in an Await
function like this:
if Await(MyAsyncFunction) then
begin
// Do Stuff
end;
And then it works
But you need to mark the method you're calling from as [async]
as well otherwise you'll get an await only available in async procedure
error.