Open the project AsyncTaskSample.dproj, and then let's talk about the AsyncTask.pas unit.
Here's the unit with some comments:
unit AsyncTask; interfaceuses System.SysUtils, System.Threading; //The PPL unit type //the "background" task TAsyncBackgroundTask<T> = reference to function: T; //the "success" callback TAsyncSuccessCallback<T> = reference to procedure(const TaskResult: T); //the "error" callback TAsyncErrorCallback = reference to procedure(const E: Exception); //the default "error" callback if the user does not provide it TAsyncDefaultErrorCallback = reference to procedure(const E: Exception; const ExptAddress: Pointer); //the main class Async = class sealed public class function Run<T>(Task: TAsyncBackgroundTask<T>; ...