I've got a button that calls a method DoSomethingUsingService(...)
that does this:
TmyWEBForm = class...
. . .
xyz : TXyz;
[async]
procedure asyncCallService( aLineNum : integer );
procedure DoSomethingUsingService(const aText: string);
. . .
implementation
. . .
procedure asyncCallService( aLineNum : integer );
begin
Log( '--- inside of asyncCallService' );
. . .
xyz := TXyx.Create;
// fill up xyz
Log( '--- xyz is ready' );
end;
procedure DoSomethingUsingService;
begin
. . .
try
. . .
Log( '+++ calling asyncCallService' );
asyncCallService( n, abc ); // this fills an object we'll call xyz of type TXyz
Log( '+++ returned from asyncCallService' );
. . .
finally
if not Assigned(xyz) then
LogError( '*** xyz is NIL' )
else
begin
Log( '+++ field1='+xyz.field1 );
Log( '+++ field2='+xyz.field2 );
. . .
end;
end;
end;
It's my understanding that the call to asyncCallService(...)
should be synchronous and block until it completes.
The problem I'm having is that it's not doing that. I've got Log statements inside of it that show this execution path:
+++ calling asyncCallService
+++ returned from asyncCallService
*** xyz is NIL
--- inside of asyncCallService
--- xyz is ready
it should be like this:
+++ calling asyncCallService
--- inside of asyncCallService
--- xyz is ready
+++ returned from asyncCallService
+++ field1=abc
+++ field2=whoosh
That is, the asyncCallService
call is not blocking, but returning immediately.
Is this what it's supposed to do? If so, how do I get the behavior I want? The stuff after the call depends on the data returned by what asyncCallService gets back.
If not ... is it a bug? Or did I miss adding an attribute or something somewhere?