From:             Luckyy <luckyy@io.com> 
Subject:          Re: [delphi] Re: Releasing CPU from Delphi DLLs 
To:               delphi-talk@bridge.net 
Date sent:        Tue, 18 Jul 1995 22:35:27 -0500 (CDT) 
Send reply to:    delphi-talk@bridge.net 
 
>  
>  
>  
> -- Hi, 
>       can anyone suggest a way that I can cause windows (3.11) to reschedule, ie  
>  release the CPU to permit other applications (or even the current application  
> to run whilst processing a DLL call?  
>      I'm writing a DLL which may require several seconds of processor time, and  
> I would like to permit the screen to continue updating (and background  
> processing to continue..... basically I'm looking for an equivalent of  
> the Doevents command in V.B. From what I have read it appears that the only way  
> to achiev this from a Delphi app. is to peek at the incomming windows message  
> queue with an appropriate set of parameters. Surely this isn't the only way to  
> effect a Doevents type reschedule. 
>  
>     Thanks in advance. 
>  
>                            Mike. 
 
Well, here's the way I use (you could also do "Application.ProcessMessages") 
 
--- cut here --- 
{ Does the same as "DoEvents()" in VB 3.0, and is about 10-20% faster than 
  calling Application.ProcessMessages } 
function DoEvents: Boolean; 
var msg: TMsg; 
begin 
     while PeekMessage(msg, 0, 0, 0, PM_REMOVE) do 
     begin 
          if msg.message = WM_QUIT then 
          begin 
               PostQuitMessage(msg.wParam); 
               DoEvents := true; 
               exit; 
          end 
          else 
          begin 
               TranslateMessage(msg); 
               DispatchMessage(msg); 
          end; 
     end; 
     DoEvents := false; 
end; 
 
--- end cut --- 
 
Hope this helps! 
 
- Luckyy 
 
 
