From: <ob...@us...> - 2006-12-12 13:40:56
|
Revision: 11077 http://svn.sourceforge.net/jvcl/?rev=11077&view=rev Author: obones Date: 2006-12-12 05:40:55 -0800 (Tue, 12 Dec 2006) Log Message: ----------- If delay is long and the application is terminated while waiting, the thread would not end until the delay is elapsed. Modified Paths: -------------- trunk/jvcl/run/JvTimer.pas Modified: trunk/jvcl/run/JvTimer.pas =================================================================== --- trunk/jvcl/run/JvTimer.pas 2006-12-10 09:18:00 UTC (rev 11076) +++ trunk/jvcl/run/JvTimer.pas 2006-12-12 13:40:55 UTC (rev 11077) @@ -159,6 +159,10 @@ end; procedure TJvTimerThread.Execute; +const + Step = 10; // Time of a wait slot, in milliseconds +var + CurrentDuration: Cardinal; function ThreadClosed: Boolean; begin @@ -195,7 +199,12 @@ end; end; - SleepEx(FInterval, False); + CurrentDuration := 0; + while not ThreadClosed and (CurrentDuration < FInterval) do + begin + SleepEx(Step, False); + Inc(CurrentDuration, Step); + end; // while we are paused, we do not do anything. However, we do call SleepEx // in the alertable state to avoid 100% CPU usage. Note that the delay This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |