Ignore:
Timestamp:
Jan 28, 2011, 7:33:14 PM (14 years ago)
Author:
george
Message:
  • Added: Displaying thread list in Demo.
  • Fixed: Terminating and freeing unused threads.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • MicroThreading/Demo/UMainForm.pas

    r156 r157  
    2828    Label11: TLabel;
    2929    Label12: TLabel;
     30    Label13: TLabel;
    3031    Label2: TLabel;
    3132    Label3: TLabel;
     
    3738    Label9: TLabel;
    3839    ListView1: TListView;
     40    ListView2: TListView;
    3941    Memo1: TMemo;
    4042    PageControl1: TPageControl;
     
    5860    procedure FormShow(Sender: TObject);
    5961    procedure ListView1Data(Sender: TObject; Item: TListItem);
     62    procedure ListView2Data(Sender: TObject; Item: TListItem);
    6063    procedure SpinEdit2Change(Sender: TObject);
    6164    procedure SpinEdit3Change(Sender: TObject);
     
    240243end;
    241244
     245procedure TMainForm.ListView2Data(Sender: TObject; Item: TListItem);
     246begin
     247  if Item.Index < MainScheduler.ThreadPoolCount then
     248  try
     249    MainScheduler.ThreadPoolLock.Acquire;
     250    with TMicroThreadThread(MainScheduler.ThreadPool[Item.Index]) do begin
     251      Item.Caption := IntToStr(ThreadID);
     252      Item.SubItems.Add(MicroThreadThreadStateText[State]);
     253    end;
     254  finally
     255    MainScheduler.ThreadPoolLock.Release;
     256  end;
     257end;
     258
    242259procedure TMainForm.SpinEdit2Change(Sender: TObject);
    243260begin
     
    256273  ListView1.Items[-1];
    257274  ListView1.Refresh;
     275
     276  if ListView2.Items.Count <> MainScheduler.ThreadPoolCount then
     277    ListView2.Items.Count := MainScheduler.ThreadPoolCount;
     278  ListView2.Items[-1];
     279  ListView2.Refresh;
     280
    258281  Label2.Caption := DateTimeToStr(NowPrecise) + ' ' +
    259282    FloatToStr(Frac(NowPrecise / OneSecond));
Note: See TracChangeset for help on using the changeset viewer.