Как вызвать TIdHTTP.Disconnect при запуске в задаче OmniThreadLibrary
Мне интересно, как я могу отключить экземпляр TIdHTTP в Delphi Seattle, пока он выполняется в анонимной процедуре CreateTask из OmniThreadLibrary.
Мой текущий код выглядит так:
task := CreateTask(
procedure(const task: IOmniTask)
var
http: TIdHTTP;
begin
http := TIdHTTP.Create;
try
http.Get('http://192.168.1.14/stats.php?recalc');
finally
http.Free;
end;
end).Run;
The request takes sometimes very long (like 40-60 seconds) and the user should have the opportunity to abort the request.
I am aware of using TIdHTTP's OnWork event, but in my case this is not suitable. OnWork gets called when there is a read/write operation, but while waiting for the server that is not the case.