From RAD Studio API Documentation
Jump to: navigation, search


function ExecuteAsync(ACompletionHandler: TCompletionHandler = nil; ASynchronized: Boolean = True;
AFreeThread: Boolean = True; ACompletionHandlerWithError: TCompletionHandlerWithError = nil): TRESTExecutionThread;


TRESTExecutionThread* __fastcall ExecuteAsync(System::Sysutils::_di_TProc ACompletionHandler = System::Sysutils::_di_TProc(), bool ASynchronized = true, bool AFreeThread = true, System::DelphiInterface<System::Sysutils::TProc__1<System::TObject*> > ACompletionHandlerWithError = System::DelphiInterface<System::Sysutils::TProc__1<System::TObject*> >());


Type Visibility Source Unit Parent
function public
REST.Client TCustomRESTRequest


Executes a request asynchronously, i.e. runs it in its own thread.

Returned Value

When the AFreeThread parameter is set to False, this method returns a reference to this execution thread.

Note: If the AFreeThread parameter is set to True, the method returns an invalid reference.


This method defines the following parameters:

  • ACompletionHandler--Specifies an anonymous method to run after completing the request execution.
  • ASynchronized--When True, specifies that the method set in ACompletionHandler runs in the main thread context. When False, ACompletionHandler runs in the execution thread context.
  • AFreeThread - When True, the execution thread is freed after completing the request execution.


While the execution thread runs, properties of all involved TCustomRESTClient and TCustomRESTRequest instances should not be accessed from other threads (including the main thread).
The use of the ExecuteAsync method is strongly recommended on mobile platforms. iOS (and likely Android) will terminate an application if it considers the main thread to be unresponsive, i.e. if a running request takes more than a second or two to return. Sluggish behavior (caused by the main thread blocking) is considered to be unacceptable on mobile devices.

See Also