Ignore:
Timestamp:
Jan 24, 2011, 4:02:40 PM (14 years ago)
Author:
george
Message:
  • Added: Global scheduler MainScheduler for direct access.
  • Added: Similar thread construction as TThread class where Execute is virtual method. Direct adding of method is supported as well.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • MicroThreading/Demo/UMainForm.pas

    r141 r142  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, ExtCtrls, UMicroThreading, Coroutine, DateUtils;
     9  ComCtrls, ExtCtrls, Spin, UMicroThreading, Coroutine, DateUtils;
    1010
    1111type
     
    2323    Button2: TButton;
    2424    Button3: TButton;
     25    Button4: TButton;
    2526    Label1: TLabel;
    2627    Label2: TLabel;
    2728    ListView1: TListView;
    2829    Memo1: TMemo;
     30    SpinEdit1: TSpinEdit;
    2931    Timer1: TTimer;
    3032    procedure Button1Click(Sender: TObject);
    3133    procedure Button2Click(Sender: TObject);
    3234    procedure Button3Click(Sender: TObject);
     35    procedure Button4Click(Sender: TObject);
    3336    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    3437    procedure FormCreate(Sender: TObject);
     
    7073begin
    7174  Scheduler := TMicroThreadScheduler.Create;
    72   Scheduler.FreeMicroThreadOnFinish := False;
    7375  Test := TTest.Create;
    7476  DoubleBuffered := True;
     
    8486    Scheduler.MicroThreads.Clear;
    8587    Memo1.Clear;
    86     for I := 0 to 20 do
    87       Scheduler.Add('Worker', Worker);
    8888    Scheduler.Start;
    8989  end else begin
     
    149149begin
    150150  Test.Invoke;
     151end;
     152
     153procedure TForm1.Button4Click(Sender: TObject);
     154var
     155  I: Integer;
     156begin
     157  for I := 0 to SpinEdit1.Value do
     158    Scheduler.AddMethod(Worker);
    151159end;
    152160
Note: See TracChangeset for help on using the changeset viewer.