[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Forms' (#lcl)

# TApplication.QueueAsyncCall

Insert a given asynchronous call into the queue

## Declaration

Source position: forms.pp line 1303

`public procedure TApplication.QueueAsyncCall(`
`const AMethod: TDataEvent;`
`Data: PtrInt`
`);`

## Arguments

`AMethod` |  | The method to be used for the asynchronous call
`Data` |  | The data structure used by the asynchronous call method

## Example

    unit TestQueueAsyncCall;

    {$mode objfpc}{$H+}

    interface

    uses
      Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
      StdCtrls;

    type

      { TQueueAsyncCallForm }

      TQueueAsyncCallForm = class(TForm)
        CallButton: TButton;
        LogListBox: TListBox;
        procedure CallButtonClick(Sender: TObject);
      private
        { private declarations }
        FCounter: PtrInt;
        procedure Async(Data: PtrInt);
      public
        { public declarations }
      end;

    var
      QueueAsyncCallForm: TQueueAsyncCallForm;

    implementation

    { TQueueAsyncCallForm }

    procedure TQueueAsyncCallForm.CallButtonClick(Sender: TObject);
    begin
      LogListBox.Items.Add('Click 1');
      FCounter := FCounter+1;
      Application.QueueAsyncCall(@Async,FCounter);
      LogListBox.Items.Add('Click 2');
    end;

    procedure TQueueAsyncCallForm.Async(Data: PtrInt);
    begin
       LogListBox.Items.Add('Async '+ IntToStr(Data));
    end;

    initialization
      {$I testqueueasynccall.lrs}

    end.

The latest version of this document can be found at lazarus-ccr.sourceforge.net .