Standard Interface Library

For Linux and Windows

All kind of list support enumerators...

The standard way The Sil way

var
  I: Integer;
  Item: Pointer; // use the correct type
...

  for I := 0 to List.Count - 1 do
  begin Item := List[I];
    // we can use Item
  end;

var
  Enum: IEnumerator;
  Item: Pointer; // use the correct type
...

  while List.Enumerate(Enum, Item) do
  begin
    // we can use Item
  end;

 

An example with threads...

The standard way The Sil way

type TMyThread = class(TThread)
   procedure Execute; override;
end;

TForm1 = class(TForm)
  procedure FormCreate(Sender: TObject);
private
  FMyThread: TMyThread;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FMyThread := TMyThread.Create(True);
  // some setup ...
  FMyThread.Resume;
end;

procedure TMyThread.Execute;
begin
  // thread code here ...
end;

type TForm1 = class(TForm, IRunnable)   procedure FormCreate(Sender: TObject);
private
  FMyThread: IThread;
protected // interface IRunnable
  procedure Run(const Thread: IThread);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
   FMyThread := Sil.Os.Thread.Spawn(Self, True);
  // some setup ...
  FMyThread.Resume;
end;

procedure TForm1.Run(const Thread: IThread);
begin
  // thread code here ...
end;

Sourceforge area

CVS

News

Downloads

SourceForge.net Logo