Question about using LOOP

Post Reply
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Question about using LOOP

Post by driessen »

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

      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. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Post by driessen »

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. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Question about using LOOP

Post by Enrico Maria Giordano »

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

Code: Select all

#pragma BEGINDUMP

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


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

#pragma ENDDUMP
EMG
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Post by driessen »

EnricoMaria,

Thanks a lot. Your suggestion just works fine.

Problem solved.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Post Reply