Ignore:
Timestamp:
Jan 24, 2011, 8:49:56 AM (14 years ago)
Author:
george
Message:
  • Added: Scheduler Start and Stop methods.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • MicroThreading/Demo/UMainForm.pas

    r140 r141  
    4141    Scheduler: TMicroThreadScheduler;
    4242    Test: TTest;
    43     Terminate: Boolean;
    44   end;
     43  end;
    4544
    4645var
     
    7372  Scheduler.FreeMicroThreadOnFinish := False;
    7473  Test := TTest.Create;
     74  DoubleBuffered := True;
     75  ListView1.DoubleBuffered := True;
    7576end;
    7677
     
    7879var
    7980  I: Integer;
    80   Executed: Integer;
    8181begin
    8282  if Button1.Caption = 'Start scheduler' then begin
    8383    Button1.Caption := 'Stop scheduler';
    84     Terminate := False;
    8584    Scheduler.MicroThreads.Clear;
    8685    Memo1.Clear;
    8786    for I := 0 to 20 do
    8887      Scheduler.Add('Worker', Worker);
    89     repeat
    90       Executed := Scheduler.Execute(10);
    91       Application.ProcessMessages;
    92       if Executed = 0 then Sleep(1);
    93     until (Scheduler.MicroThreadCount = 0) or Terminate;
     88    Scheduler.Start;
    9489  end else begin
    9590    Button1.Caption := 'Start scheduler';
    96     Terminate := True;
     91    Scheduler.Stop;
    9792  end;
    9893end;
     
    158153procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    159154begin
    160   Terminate := True;
     155  Scheduler.Stop;
    161156end;
    162157
Note: See TracChangeset for help on using the changeset viewer.