TCountdownEvent (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example illustrates the use of the TCountdownEvent class.

Code

program TCountdownEvent_example;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  SyncObjs,
  Classes;

var
  RunwayFlag: TCountdownEvent;

type
  TThreadIgnite = class(TThread)
  private
    procedure Execute; override;
  end;

procedure TThreadIgnite.Execute;
begin
  RunwayFlag.WaitFor();
  Writeln('Ignited');
end;

var
  Thread: TThreadIgnite;

begin
  RunwayFlag := TCountdownEvent.Create(200);
  RunwayFlag.Reset;

  Thread := TThreadIgnite.Create(True);
  Thread.Start;

  while not RunwayFlag.IsSet do
  begin
    RunwayFlag.Signal;
    Writeln(RunwayFlag.CurrentCount);
  end;

end. { Put breakpoint here to see the console output. }

Uses