Changeset 159 for MicroThreading/Demo/UMainForm.pas
- Timestamp:
- Jan 31, 2011, 2:16:21 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/UMainForm.pas
r158 r159 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, ExtCtrls, Spin, UMicroThreading, DateUtils, UPlatform; 9 ComCtrls, ExtCtrls, Spin, UMicroThreading, DateUtils, UPlatform, 10 UMicroThreadList; 10 11 11 12 type 12 13 13 TMainForm = class; 14 14 … … 28 28 Button2: TButton; 29 29 Button3: TButton; 30 Button4: TButton; 30 31 ButtonAddWorkers: TButton; 31 32 ButtonClearMicroThreads: TButton; … … 40 41 GroupBox2: TGroupBox; 41 42 GroupBox3: TGroupBox; 42 Label1: TLabel;43 43 Label10: TLabel; 44 44 Label11: TLabel; … … 57 57 Label8: TLabel; 58 58 Label9: TLabel; 59 ListView1: TListView;60 59 ListView2: TListView; 61 60 Memo1: TMemo; … … 72 71 procedure Button1Click(Sender: TObject); 73 72 procedure Button3Click(Sender: TObject); 73 procedure Button4Click(Sender: TObject); 74 74 procedure ButtonSchedulerStartStopClick(Sender: TObject); 75 75 procedure Button2Click(Sender: TObject); … … 85 85 procedure FormDestroy(Sender: TObject); 86 86 procedure FormShow(Sender: TObject); 87 procedure ListView1Data(Sender: TObject; Item: TListItem);88 87 procedure ListView2Data(Sender: TObject; Item: TListItem); 89 88 procedure SpinEdit2Change(Sender: TObject); … … 92 91 procedure TimerRedrawTimer(Sender: TObject); 93 92 private 93 MicroThreadList: TMicroThreadList; 94 94 procedure WorkerSubRoutine; 95 95 public … … 117 117 begin 118 118 DoubleBuffered := True; 119 ListView1.DoubleBuffered := True;119 // ListView1.DoubleBuffered := True; 120 120 Label6.Caption := IntToStr(GetLogicalProcessorCount); 121 121 Event := TMicroThreadEvent.Create; 122 MicroThreadList := TMicroThreadList.Create(Self); 122 123 end; 123 124 … … 144 145 begin 145 146 Event.SetEvent; 147 end; 148 149 procedure TMainForm.Button4Click(Sender: TObject); 150 begin 151 MicroThreadList.Form.Show; 146 152 end; 147 153 … … 268 274 procedure TMainForm.FormDestroy(Sender: TObject); 269 275 begin 276 MicroThreadList.Free; 270 277 MainScheduler.Active := False; 271 278 Event.Free; … … 279 286 ButtonSchedulerStartStop.Click; 280 287 Label16.Caption := IntToStr(MainThreadID); 281 end;282 283 procedure TMainForm.ListView1Data(Sender: TObject; Item: TListItem);284 begin285 try286 MainScheduler.MicroThreadsLock.Acquire;287 if Item.Index < MainScheduler.MicroThreads.Count then288 with TMicroThread(MainScheduler.MicroThreads[Item.Index]) do begin289 Item.Caption := IntToStr(Id);290 Item.SubItems.Add('');291 Item.SubItems.Add(IntToStr(Priority));292 Item.SubItems.Add(MicroThreadStateText[State]);293 Item.SubItems.Add(MicroThreadBlockStateText[BlockState]);294 Item.SubItems.Add(FloatToStr(ExecutionTime));295 Item.SubItems.Add(IntToStr(ExecutionCount));296 Item.SubItems.Add(IntToStr(Trunc(Completion * 100)) + '%');297 Item.SubItems.Add(IntToStr(StackUsed));298 Item.SubItems.Add(Name);299 end;300 finally301 MainScheduler.MicroThreadsLock.Release;302 end;303 288 end; 304 289 … … 334 319 procedure TMainForm.TimerRedrawTimer(Sender: TObject); 335 320 begin 336 if ListView1.Items.Count <> MainScheduler.MicroThreadCount then337 ListView1.Items.Count := MainScheduler.MicroThreadCount;338 ListView1.Items[-1];339 ListView1.Refresh;340 341 321 if ListView2.Items.Count <> MainScheduler.ThreadPoolCount then 342 322 ListView2.Items.Count := MainScheduler.ThreadPoolCount;
Note:
See TracChangeset
for help on using the changeset viewer.