Re: Delay or suspend Application waiting for thread to complete
- From: "Paul E. Schoen" <pstech@xxxxxxxxx>
- Date: Wed, 11 Jan 2006 01:33:23 -0500
I think I found the answer to my problem. If I use a loop that includes a
call to Application.ProcessMessages, all processes, including the timer and
threads, seem to run OK. A simple implementation is attached. A thread can
stop the delay by setting DelayObject.Timeout := 0, but there may be a
problem if the DelayObject has been destroyed because of a timeout. Any
suggestions are welcome!
I found the clue in an old web page I found at:
http://www.mindspring.com/~cityzoo/tips/tips.html
procedure TForm1.Delay(msecs:integer);
var
FirstTickCount:longint;
begin
FirstTickCount:=GetTickCount;
repeat
Application.ProcessMessages; {allowing access to other
controls, etc.}
until ((GetTickCount-FirstTickCount) >= Longint(msecs));
end;
begin 666 Delay.pas
M=6YI="!$96QA>3L-"@T*:6YT97)F86-E#0IU<V5S#0H@(%=I;F1O=W,L($UE
M<W-A9V5S+"!3>7-5=&EL<RP@0VQA<W-E<RP@4W1D0W1R;',L($5X=$-T<FQS
M+"!/<G1,:6(Q.PT*#0IT>7!E#0H@(%1/8FIE8W0Q(#T@8VQA<W,H5$]B:F5C
M="D-"B @("!4:6UE<C$Z(%14:6UE<CL-"B @("!P<F]C961U<F4@5&EM97(Q
M5&EM97(H4V5N9&5R.B!43V)J96-T*3L-"B @<')I=F%T90T*(" @('L@4')I
M=F%T92!D96-L87)A=&EO;G,@?0T*("!P=6)L:6,-"B @("![(%!U8FQI8R!D
M96-L87)A=&EO;G,@?0T*("!E;F0[#0H-"G9A<@T*("!/8FIE8W0Q.B!43V)J
M96-T,3L-"B\O("!4:6UE;W5T.B!);G1E9V5R.PT*#0IP<F]C961U<F4@(" @
M($1E;&%Y*"!C;VYS="!-<V5C.B!);G1E9V5R("D[#0H-"FEM<&QE;65N=&%T
M:6]N#0H-"G!R;V-E9'5R92 @(" @1&5L87DH(&-O;G-T($US96,Z($EN=&5G
M97(@*3L-"G9A<B @(" @(" @(" @9E1I;65R179E;G0Z(%1.;W1I9GE%=F5N
M=#L-"F)E9VEN#0H@($]B:F5C=#$@.CT@5$]B:F5C=#$N0W)E871E.PT*("!/
M<G1,:6(Q+E1I;65O=70@.CT@;5-E8SL-"B @3V)J96-T,2Y4:6UE<C$@.CT@
M5%1I;65R+D-R96%T92AN:6PI.PT*("!/8FIE8W0Q+E1I;65R,2Y);G1E<G9A
M;" Z/2 Q,# [#0H@(&94:6UE<D5V96YT(#H]($]B:F5C=#$N5&EM97(Q5&EM
M97([#0H@($]B:F5C=#$N5&EM97(Q+D]N5&EM97(@.CT@9E1I;65R179E;G0[
M#0IE;F0[#0H-"G!R;V-E9'5R92!43V)J96-T,2Y4:6UE<C%4:6UE<BA396YD
M97(Z(%1/8FIE8W0I.PT*8F5G:6X-"B @268@3W)T3&EB,2Y4:6UE3W5T(#X@
M,"!T:&5N#0H@(" @3W)T3&EB,2Y4:6UE3W5T(#H]($]R=$QI8C$N5&EM94]U
M=" M(#$P, T*("!E;'-E#0H@(" @3V)J96-T,2Y&<F5E.PT*96YD.PT*#0IE
%;F0N#0H`
`
end
.
- References:
- Delay or suspend Application waiting for thread to complete
- From: Paul E. Schoen
- Delay or suspend Application waiting for thread to complete
- Prev by Date: Re: Getting the text under the cursor from any application
- Next by Date: Re: Fast Copy to Canvas Method
- Previous by thread: Delay or suspend Application waiting for thread to complete
- Next by thread: Re: Delay or suspend Application waiting for thread to complete
- Index(es):
Relevant Pages
|