Ignore:
Timestamp:
Jan 28, 2011, 2:12:42 PM (14 years ago)
Author:
george
Message:
  • Modified: Restructuralized code for support for pending state changes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • MicroThreading/Demo/UMainForm.pas

    r155 r156  
    4646    TabSheet3: TTabSheet;
    4747    TimerRedraw: TTimer;
    48     TimerSchedulerStart: TTimer;
    4948    procedure Button1Click(Sender: TObject);
    5049    procedure ButtonSchedulerStartStopClick(Sender: TObject);
     
    6261    procedure SpinEdit3Change(Sender: TObject);
    6362    procedure TimerRedrawTimer(Sender: TObject);
    64     procedure TimerSchedulerStartTimer(Sender: TObject);
    6563  private
    6664    procedure Worker(MicroThread: TMicroThread);
     
    215213begin
    216214  Iterations := SpinEdit3.Value;
     215  SpinEdit2.Value := 20;
     216  ButtonAddWorkers.Click;
     217  ButtonSchedulerStartStop.Click;
    217218end;
    218219
     
    224225    with TMicroThread(MainScheduler.MicroThreads[Item.Index]) do begin
    225226      Item.Caption := IntToStr(Id);
    226       Item.SubItems.Add(Name);
    227227      Item.SubItems.Add('');
    228228      Item.SubItems.Add(IntToStr(Priority));
     
    230230      Item.SubItems.Add(MicroThreadBlockStateText[BlockState]);
    231231      Item.SubItems.Add(FloatToStr(ExecutionTime));
     232      Item.SubItems.Add(IntToStr(ExecutionCount));
    232233      Item.SubItems.Add(IntToStr(Trunc(Completion * 100)) + '%');
    233234      Item.SubItems.Add(IntToStr(StackUsed));
     235      Item.SubItems.Add(Name);
    234236    end;
    235237  finally
     
    260262end;
    261263
    262 procedure TMainForm.TimerSchedulerStartTimer(Sender: TObject);
    263 begin
    264   TimerSchedulerStart.Enabled := False;
    265   ButtonAddWorkers.Click;
    266   ButtonSchedulerStartStop.Click;
    267 end;
    268 
    269264procedure TMainForm.WorkerSubRoutine;
    270265begin
    271   MTSleep(1 * OneMillisecond);
     266  //MTSleep(1 * OneMillisecond);
    272267end;
    273268
     
    282277      Q := 0;
    283278      while Q < 100 do Inc(Q);
    284       Synchronize(WorkerDoWrite);
     279      //Synchronize(WorkerDoWrite);
    285280      //Memo1.Lines.Add(IntToStr(Id) + ': ' + IntToStr(I) + ' ' +
    286281      //  FloatToStr(ExecutionTime));
    287282      Completion := I / Iterations;
    288       //MTSleep(1 * Id * OneMillisecond);
     283      //MTSleep(1000 * OneMillisecond);
    289284      Yield;
    290       WorkerSubRoutine;
     285      //WorkerSubRoutine;
    291286    end;
    292287  end;
     
    295290procedure TMainForm.WorkerDoWrite;
    296291begin
    297   Memo1.Lines.Add('.');
     292  //Memo1.Lines.Add('.');
    298293end;
    299294
Note: See TracChangeset for help on using the changeset viewer.