In/out value in callback

(Alessandro) #1

Hi!

i have a question…. i got 2 variables in/out when send message to server but i don t understand how to take data in callback.

i got:
BeginWriteDataEdit(Inout1,Inout2, Callback_WriteData);

procedure Callback_WriteData(const aRequest: IROAsyncRequest);
var
Result_Back: Boolean;
begin
if (not aRequest.Cancelled) then
begin

  Result_Back := GetService.EndWriteDataEdit(aRequest);

end;
end;

how can i use Inout1,Inout2 in callback functions?

(EvgenyK) #2

for

  INewService = interface(IROService)
  ['{EC634843-9830-4A07-90DE-165505D19808}']
    procedure NewMethod(var NewParam: ROAnsiString; var NewParam1: ROAnsiString);
  end;

it generates such AsyncEx:

  INewService_AsyncEx = interface(IROAsyncInterfaceEx)
    function BeginNewMethod(var NewParam: ROAnsiString; var NewParam1: ROAnsiString; const aCallback: TROAsyncCallback; const aUserData: Pointer = nil): IROAsyncRequest;
    procedure EndNewMethod(out NewParam: ROAnsiString; out NewParam1: ROAnsiString; const aRequest: IROAsyncRequest);
  end;

so you can receive in/out parameters w/o any problems.

Can you show _AsyncEx interface that contains EndWriteDataEdit method ?

(Alessandro) #3

Hi
I have this one:
function BeginTakemyData(const PcDate: DateTime; const aCallback: TROAsyncCallback; const aUserData: Pointer = nil): IROAsyncRequest;

function EndTakemyData(out param1: Boolean; out param2: Integer; out param3: DateTime; const aRequest: IROAsyncRequest): TBack_Struct_Array;

my callback func is:

procedure TakeMyData_Monitor_callback (out param1: Boolean; out param2: Integer; out param3: DateTime; const aRequest: IROAsyncRequest);

i use:

getservice.BeginTakemyData(now(),TakeMyData_Monitor_callback);

but i got compilation problem
Parameter list differs

(EvgenyK) #4

callback method should have one parameter like

procedure Callback_DownloadPhoto(const aRequest: IROAsyncRequest);

pls review the Phone Photo Server sample - it demonstrates usage of AsyncEx interfaces

(Alessandro) #5

ok callback in photo server have only input data
i need to send back param1,param2,param3 that are out variable. How can i do?

(EvgenyK) #6

something like

procedure TakeMyData_Monitor_callback (const aRequest: IROAsyncRequest);
..
begin
  if (not aRequest.Cancelled) then begin
      lr := GetService.EndTakemyData(param1, param2, param3, aRequest);
      ...
  end;
end;
(Alessandro) #7

Thank you

when arequest.cancelled occurs?

(EvgenyK) #8

when you manually Cancel request like

xxxx := getservice.BeginTakemyData(now(),TakeMyData_Monitor_callback);
...
xxxx.Cancel;