FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Question about using LOOP
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about using LOOP
Posted: Wed Jun 13, 2007 01: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 :

      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. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Question about using LOOP
Posted: Wed Jun 13, 2007 02:44 PM
Try replacing SYSREFRESH() with

HB_IDLESLEEP( 1 )


EMG
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about using LOOP
Posted: Wed Jun 13, 2007 03: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. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Question about using LOOP
Posted: Wed Jun 13, 2007 03:41 PM
Then try using SLEEP() instead of HB_IDLESLEEP():

#pragma BEGINDUMP

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


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

#pragma ENDDUMP


EMG
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about using LOOP
Posted: Wed Jun 13, 2007 09: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. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion