Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.070 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: Anonymous Methods für Sanduhr als Design Pattern

  Alt 8. Dez 2015, 16:39
Delphi-Quellcode:
unit Unit1;

interface

uses
  System.Classes,
  Vcl.Controls,
  Vcl.Forms;

type
  TADOQuery = class

  end;

  TQueryProc = reference to procedure(aQuery: TADOQuery);

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
  public
    procedure ExecuteSQL1(aQuery: TADOQuery);
    procedure ExecuteSQL2(aQuery: TADOQuery);
    procedure ExecuteSQL3(aQuery: TADOQuery);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure ShowHourGlassDuringSQL(const Proc: TQueryProc; const Query : TADOQuery);
var
  OldCursor: TCursor;
begin
  OldCursor := Screen.Cursor;
  Screen.Cursor := crHourGlass;
  try
    Proc(Query);
  finally
    Screen.Cursor := OldCursor
  end;
end;

procedure TForm1.ExecuteSQL1(aQuery: TADOQuery);
begin

end;

procedure TForm1.ExecuteSQL2(aQuery: TADOQuery);
begin

end;

procedure TForm1.ExecuteSQL3(aQuery: TADOQuery);
begin

end;

procedure TForm1.FormCreate(Sender: TObject);
var
  LQuery: TADOQuery;
begin
  LQuery:= TADOQuery.Create;
  ShowHourGlassDuringSQL(ExecuteSQL1, LQuery);
  ShowHourGlassDuringSQL(ExecuteSQL2, LQuery);
  ShowHourGlassDuringSQL(ExecuteSQL3, LQuery);
end;

end.
  Mit Zitat antworten Zitat