AsyncEx Question

HI,

I use AsyncEx Interface to call Long running function ( Data calculation say 5 min).

However, the function seems return on 2 minutes after even the process in server side still running.

Delphi : 10.2, RO/DA: 9.3.105.1351

Is it any timeout Setting or any setting trigger this?

My Code is like below:

#Create the Intreface:

MySyn := CoMy_AsyncEx.Create(Message,ROSuperTCPChannel);

myReq:= MySyn.BeginGET_CM_KB( MyCallBack);

procedure MyCallBack(const aRequest: IROAsyncRequest);
var
lData,sDir: String;
sLst:TStringList;
UpdatedBin:Binary;
begin
TxtLog.Send(‘Done Syn Request:’+IntToStr(Ord(aRequest.Cancelled)));

try
if (not aRequest.Cancelled) then
begin
UpdatedBin:= MySyn.EndGET_CM_KB(aRequest);
cdsSynList.RemoteFetchEnabled := False;
cdsSynList.LogicalName := ‘ASYN_VIEW’;
DABin2DataStreamer.ReadDataset(UpdatedBin,cdsSynList,True);
TxtLogSend(cdsSynList.Fields[0].AsString+’:’+cdsSynList.Fields[1].AsString);
end
Else
TxtLog.Send(‘Done Syn Request----Done:’+IntToStr(Ord(aRequest.Done)));
finally
if aRequest = myReq then myReq := nil;
end;
end;

The above method come out error on timeout and go to the callback function

Please advise what I m missing in order to run long running process.

Hi,
have you tried to increase value of ClientChannel.RequestTimeout property ?

It is ok when increase this value but any potential issue on this?
or what is the guideline on setting this value?

Hi,

this value should be great than time of execution of the longest method of server-side

by other way, you can replace it with two methods and event.
when client-side receives the specific event, it should call server-side method and get result of long method

Any Example Code ?

it can be something like this:20384.zip (110.7 KB)

Hi Evgeny,

Question regarding that example. When the StartLongMethod is invoked, it will be received on the server side on a new thread. Is it safe to assume than when you create a task and run it inside of this thread, the thread will continue its execution leaving the task running and doing the Event Sink after its done?

Would we have a memory leak on the server side while doing this?

Hi,

what object should be leaked by your opinion? is service itself? it is interface so it will be destroyed when refcount = 0.
if you add fastmm4 into server-side project, it won’t generate any report about memory leaks so this code is safe.

1 Like