Changeset 463 for branches/highdpi/Packages/Common/Threading.pas
- Timestamp:
- Nov 29, 2023, 2:35:44 PM (12 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/Common/Threading.pas
r462 r463 1 unit UThreading; 2 3 {$mode delphi} 1 unit Threading; 4 2 5 3 interface 6 4 7 5 uses 8 UDpiControls, Classes, SysUtils, Forms, Contnrs, SyncObjs;6 UDpiControls, Classes, SysUtils, Forms, Generics.Collections, SyncObjs; 9 7 10 8 type 11 9 TExceptionEvent = procedure (Sender: TObject; E: Exception) of object; 12 10 TMethodCall = procedure of object; 13 14 11 15 12 { TVirtualThread } … … 22 19 function GetSuspended: Boolean; virtual; abstract; 23 20 function GetTerminated: Boolean; virtual; abstract; 24 function GetThreadId: Integer; virtual; abstract;21 function GetThreadId: TThreadID; virtual; abstract; 25 22 procedure SetFreeOnTerminate(const AValue: Boolean); virtual; abstract; 26 23 procedure SetPriority(const AValue: TThreadPriority); virtual; abstract; … … 42 39 property Terminated: Boolean read GetTerminated write SetTerminated; 43 40 property Finished: Boolean read GetFinished; 44 property ThreadId: Integerread GetThreadId;41 property ThreadId: TThreadID read GetThreadId; 45 42 end; 46 43 … … 68 65 function GetSuspended: Boolean; override; 69 66 function GetTerminated: Boolean; override; 70 function GetThreadId: Integer; override;67 function GetThreadId: TThreadID; override; 71 68 procedure SetFreeOnTerminate(const AValue: Boolean); override; 72 69 procedure SetPriority(const AValue: TThreadPriority); override; … … 102 99 { TThreadList } 103 100 104 TThreadList = class(TObjectList )105 function FindById(Id: Integer): TVirtualThread;101 TThreadList = class(TObjectList<TVirtualThread>) 102 function FindById(Id: TThreadID): TVirtualThread; 106 103 constructor Create; virtual; 107 104 end; … … 164 161 if MainThreadID = ThreadID then Method 165 162 else begin 166 Thread := ThreadList.FindById(ThreadID); 163 try 164 ThreadListLock.Acquire; 165 Thread := ThreadList.FindById(ThreadID); 166 finally 167 ThreadListLock.Release; 168 end; 167 169 if Assigned(Thread) then begin 168 170 Thread.Synchronize(Method); … … 173 175 { TThreadList } 174 176 175 function TThreadList.FindById(Id: Integer): TVirtualThread;177 function TThreadList.FindById(Id: TThreadID): TVirtualThread; 176 178 var 177 179 I: Integer; 178 180 begin 179 181 I := 0; 180 while (I < ThreadList.Count) and (T VirtualThread(ThreadList[I]).ThreadID <> Id) do182 while (I < ThreadList.Count) and (ThreadList[I].ThreadID <> Id) do 181 183 Inc(I); 182 if I < ThreadList.Count then Result := T VirtualThread(ThreadList[I])184 if I < ThreadList.Count then Result := ThreadList[I] 183 185 else Result := nil; 184 186 end; … … 233 235 end; 234 236 235 function TListedThread.GetThreadId: Integer;237 function TListedThread.GetThreadId: TThreadID; 236 238 begin 237 239 Result := FThread.ThreadID; … … 290 292 end; 291 293 FThread.Free; 292 inherited Destroy;294 inherited; 293 295 end; 294 296 … … 364 366 365 367 end. 366
Note:
See TracChangeset
for help on using the changeset viewer.