REST.Client.TCustomRESTRequest.ExecuteAsync

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

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

C++

TRESTExecutionThread* __fastcall ExecuteAsync(System::Sysutils::_di_TProc ACompletionHandler = System::Sysutils::_di_TProc(), bool ASynchronized = true, bool AFreeThread = true);

Properties

Type Visibility Source Unit Parent
function public
REST.Client.pas
REST.Client.hpp
REST.Client TCustomRESTRequest

Description

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.

Parameters

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.

Details

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