Changeset 151 for MicroThreading/Demo/UMainForm.pas
- Timestamp:
- Jan 27, 2011, 8:05:33 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/UMainForm.pas
r150 r151 26 26 Label10: TLabel; 27 27 Label11: TLabel; 28 Label12: TLabel; 28 29 Label2: TLabel; 29 30 Label3: TLabel; … … 39 40 SpinEdit1: TSpinEdit; 40 41 SpinEdit2: TSpinEdit; 42 SpinEdit3: TSpinEdit; 41 43 TabSheet1: TTabSheet; 42 44 TabSheet2: TTabSheet; … … 57 59 procedure ListView1Data(Sender: TObject; Item: TListItem); 58 60 procedure SpinEdit2Change(Sender: TObject); 61 procedure SpinEdit3Change(Sender: TObject); 59 62 procedure TimerRedrawTimer(Sender: TObject); 60 63 procedure TimerSchedulerStartTimer(Sender: TObject); … … 62 65 procedure Worker(MicroThread: TMicroThread); 63 66 public 67 Iterations: Integer; 64 68 Scheduler: TMicroThreadScheduler; 65 69 end; … … 209 213 procedure TMainForm.FormShow(Sender: TObject); 210 214 begin 215 Iterations := SpinEdit3.Value; 211 216 end; 212 217 … … 236 241 end; 237 242 243 procedure TMainForm.SpinEdit3Change(Sender: TObject); 244 begin 245 Iterations := SpinEdit3.Value; 246 end; 247 238 248 procedure TMainForm.TimerRedrawTimer(Sender: TObject); 239 249 begin 240 ListView1.Items.Count := Scheduler.MicroThreadCount; 250 if ListView1.Items.Count <> Scheduler.MicroThreadCount then 251 ListView1.Items.Count := Scheduler.MicroThreadCount; 241 252 ListView1.Items[-1]; 242 253 ListView1.Refresh; … … 258 269 I: Integer; 259 270 Q: Integer; 260 const261 TotalSteps = 100;262 271 begin 263 272 with MicroThread do begin 264 273 //Memo1.Lines.Add('Worker ' + IntToStr(Id)); 265 for I := 0 to TotalSteps - 1 do begin274 for I := 0 to Iterations - 1 do begin 266 275 Q := 0; 267 while Q < 100 00do Inc(Q);276 while Q < 100 do Inc(Q); 268 277 //Memo1.Lines.Add(IntToStr(Id) + ': ' + IntToStr(I) + ' ' + 269 278 // FloatToStr(ExecutionTime)); 270 Completion := I / TotalSteps;279 Completion := I / Iterations; 271 280 //Sleep(1 * Id * OneMillisecond); 272 281 Yield;
Note:
See TracChangeset
for help on using the changeset viewer.