Ignore:
Timestamp:
Sep 6, 2012, 8:29:27 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Balíček ModularSystem namísto vlastní implementace.
  • Upraveno: Aktualizace balíčku Common.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UThreading.pas

    r84 r89  
    1717  TVirtualThread = class
    1818  private
     19    function GetFinished: Boolean; virtual; abstract;
    1920    function GetFreeOnTerminate: Boolean; virtual; abstract;
    2021    function GetPriority: TThreadPriority; virtual; abstract;
     
    4243    property Priority: TThreadPriority read GetPriority write SetPriority;
    4344    property Terminated: Boolean read GetTerminated write SetTerminated;
     45    property Finished: Boolean read GetFinished;
    4446    property ThreadId: Integer read GetThreadId;
    4547  end;
     
    6163  private
    6264    FTerminated: Boolean;
     65    FFinished: Boolean;
    6366    FThread: TListedThreadExecute;
     67    function GetFinished: Boolean; override;
    6468    function GetFreeOnTerminate: Boolean; override;
    6569    function GetPriority: TThreadPriority; override;
     
    160164procedure Synchronize(Method: TMethodCall);
    161165var
    162   I: Integer;
    163166  Thread: TVirtualThread;
    164167begin
     
    172175end;
    173176
    174 
    175177{ TThreadList }
    176178
     
    196198begin
    197199  try
    198     Parent.Execute;
    199   except
    200     on E: Exception do
    201       if Assigned(OnException) then
    202         OnException(Parent.FThread, E);
     200    try
     201      Parent.Execute;
     202    except
     203      on E: Exception do
     204        if Assigned(OnException) then
     205          OnException(Parent.FThread, E);
     206    end;
     207  finally
     208    Parent.FFinished := True;
    203209  end;
    204210end;
    205211
    206212{ TListedThread }
     213
     214function TListedThread.GetFinished: Boolean;
     215begin
     216  Result := FFinished;
     217end;
    207218
    208219function TListedThread.GetFreeOnTerminate: Boolean;
     
    255266  const StackSize: SizeUInt);
    256267begin
     268  FFinished := False;
     269  FTerminated := False;
     270
    257271  FThread := TListedThreadExecute.Create(True, StackSize);
    258272  FThread.Parent := Self;
     
    289303  I: Integer;
    290304begin
     305  if Terminated then Exit;
    291306  SysUtils.Sleep(Delay mod Quantum);
    292307  for I := 1 to (Delay div Quantum) do begin
Note: See TracChangeset for help on using the changeset viewer.