Changeset 89 for trunk/Packages/Common/UThreading.pas
- Timestamp:
- Sep 6, 2012, 8:29:27 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UThreading.pas
r84 r89 17 17 TVirtualThread = class 18 18 private 19 function GetFinished: Boolean; virtual; abstract; 19 20 function GetFreeOnTerminate: Boolean; virtual; abstract; 20 21 function GetPriority: TThreadPriority; virtual; abstract; … … 42 43 property Priority: TThreadPriority read GetPriority write SetPriority; 43 44 property Terminated: Boolean read GetTerminated write SetTerminated; 45 property Finished: Boolean read GetFinished; 44 46 property ThreadId: Integer read GetThreadId; 45 47 end; … … 61 63 private 62 64 FTerminated: Boolean; 65 FFinished: Boolean; 63 66 FThread: TListedThreadExecute; 67 function GetFinished: Boolean; override; 64 68 function GetFreeOnTerminate: Boolean; override; 65 69 function GetPriority: TThreadPriority; override; … … 160 164 procedure Synchronize(Method: TMethodCall); 161 165 var 162 I: Integer;163 166 Thread: TVirtualThread; 164 167 begin … … 172 175 end; 173 176 174 175 177 { TThreadList } 176 178 … … 196 198 begin 197 199 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; 203 209 end; 204 210 end; 205 211 206 212 { TListedThread } 213 214 function TListedThread.GetFinished: Boolean; 215 begin 216 Result := FFinished; 217 end; 207 218 208 219 function TListedThread.GetFreeOnTerminate: Boolean; … … 255 266 const StackSize: SizeUInt); 256 267 begin 268 FFinished := False; 269 FTerminated := False; 270 257 271 FThread := TListedThreadExecute.Create(True, StackSize); 258 272 FThread.Parent := Self; … … 289 303 I: Integer; 290 304 begin 305 if Terminated then Exit; 291 306 SysUtils.Sleep(Delay mod Quantum); 292 307 for I := 1 to (Delay div Quantum) do begin
Note:
See TracChangeset
for help on using the changeset viewer.