Changeset 141 for MicroThreading/Demo/UMainForm.pas
- Timestamp:
- Jan 24, 2011, 8:49:56 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/UMainForm.pas
r140 r141 41 41 Scheduler: TMicroThreadScheduler; 42 42 Test: TTest; 43 Terminate: Boolean; 44 end; 43 end; 45 44 46 45 var … … 73 72 Scheduler.FreeMicroThreadOnFinish := False; 74 73 Test := TTest.Create; 74 DoubleBuffered := True; 75 ListView1.DoubleBuffered := True; 75 76 end; 76 77 … … 78 79 var 79 80 I: Integer; 80 Executed: Integer;81 81 begin 82 82 if Button1.Caption = 'Start scheduler' then begin 83 83 Button1.Caption := 'Stop scheduler'; 84 Terminate := False;85 84 Scheduler.MicroThreads.Clear; 86 85 Memo1.Clear; 87 86 for I := 0 to 20 do 88 87 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; 94 89 end else begin 95 90 Button1.Caption := 'Start scheduler'; 96 Terminate := True;91 Scheduler.Stop; 97 92 end; 98 93 end; … … 158 153 procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction); 159 154 begin 160 Terminate := True;155 Scheduler.Stop; 161 156 end; 162 157
Note:
See TracChangeset
for help on using the changeset viewer.