Question about using LOOP

Question about using LOOP

Postby driessen » Wed Jun 13, 2007 1:42 pm

Hello,

In my application, I use OLE to work together with MS-Word.

While working in Word, my application needs to wait until a button is pushed which end Word.

For waiting, I use this code :

Code: Select all  Expand view
      DO WHILE .T.
         IF VActive
            SYSREFRESH()
            LOOP
         ENDIF
         EXIT
      ENDDO


When VActive = .F., the loop is ended and my application continues.

While my application is waiting, I often notice that the processor is used 100 %. This is eventually slowing down other running applications.

Is there a possibility to prevent that the processor is used for 100 % ?

I use Windows XP Professional and Microsoft Office 2003. My PC has 1 GB RAM.

Thanks a lot for any help.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Question about using LOOP

Postby Enrico Maria Giordano » Wed Jun 13, 2007 2:44 pm

Try replacing SYSREFRESH() with

Code: Select all  Expand view
HB_IDLESLEEP( 1 )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby driessen » Wed Jun 13, 2007 3:33 pm

EnricoMaria,

Thanks for you help.

I tried it, but if I push the button after having worked in Word, my application hangs completely.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Question about using LOOP

Postby Enrico Maria Giordano » Wed Jun 13, 2007 3:41 pm

Then try using SLEEP() instead of HB_IDLESLEEP():

Code: Select all  Expand view
#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"


HB_FUNC( SLEEP )
{
    Sleep( hb_parnl( 1 ) );
}

#pragma ENDDUMP


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby driessen » Wed Jun 13, 2007 9:13 pm

EnricoMaria,

Thanks a lot. Your suggestion just works fine.

Problem solved.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 43 guests