We have calls that may take hours to complete and have been using the classical way to deal with this, which is to increase the timeout.
This works but it’s annoying to wait that long for a true “connection lost” scenario so I have started using the Async way of doing things, like this:
var Request :=
FAsyncService.BeginLengthyCall(Param1, Param2, Param3,
procedure (const aRequest: IROAsyncRequest)
var TotalWaitTime := 0;
while not Request.Done and (TotalWaitTime < 4 * 60 * 60 * 1000) do
if Request.Done then
ResultValue := FAsyncService.EndLengthyCall(OutParameter, Request);
raise EMyTimeout.Create('Timeout waiting for LengthyCall completion');
While this works when LengthyCall is responding fast (say less than 10 minutes), I sometimes get EROTimeout exceptions when the call has waited for about 3 hours.
This is the call stack that I get:
I realize that it was not clear in my message above, but I’m already using the AsyncEx methods, with an empty callback, I agree.
What I want is for TMyClass.DoSomething to wait for the async call to complete, hence its own internal loop.
And if I read things correctly, the callback will be triggered when the call has completed, but I still have to call EndLengthyCall to get the result and out parameters. And it is this call that is sending me the EROTimeout exception.
Well, yes, that’s exactly what happens because there are connectivity issues in the network I’m using.
But I thought that this was exactly the purpose of the Async interface in that it would simply be bling to micro interruptions at the network level because it does not keep the connection up.
As it turns out, this is not the case and I’ll have to go back to the previous method.