Changeset 261
- Timestamp:
- Aug 9, 2011, 10:44:42 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/UThreading.pas
r258 r261 83 83 end; 84 84 85 TTermThreadState = (ttsReady, ttsRunning, ttsFinished, ttsExceptionOccured); 86 85 87 { TTermThread } 86 88 … … 88 90 private 89 91 public 90 Finished: Boolean; 92 State: TTermThreadState; 93 ExceptionMessage: string; 91 94 Method: TMethodCall; 92 95 procedure Execute; override; … … 123 126 Thread.Resume; 124 127 Thread.Method := Method; 125 while not Thread.Finisheddo begin128 while (Thread.State = ttsRunning) or (Thread.State = ttsReady) do begin 126 129 if MainThreadID = ThreadID then Application.ProcessMessages; 127 130 Sleep(1); 128 131 end; 132 if Thread.State = ttsExceptionOccured then 133 raise Exception.Create(Thread.ExceptionMessage); 129 134 finally 130 135 Thread.Free; … … 316 321 begin 317 322 try 323 State := ttsRunning; 318 324 Method; 319 Finished := True;325 State := ttsFinished; 320 326 except 321 327 on E: Exception do 322 if Assigned(OnException) then 328 if Assigned(OnException) then begin 323 329 OnException(FThread, E); 330 ExceptionMessage := E.Message; 331 State := ttsExceptionOccured; 332 end; 324 333 end; 325 334 end;
Note:
See TracChangeset
for help on using the changeset viewer.