FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for CA-Clipper WaitRun using 100% processor time
Posts: 159
Joined: Wed Mar 28, 2007 01:19 PM
WaitRun using 100% processor time
Posted: Tue Nov 22, 2011 11:48 AM

Hi to all,
I have some old sistems in FW and Clipper and for several resons, I did not convert them to FWH.
Instead, I wrote routines to access internet data in FWH and intended to call them with WaitRun() from the FW Clipper sistems.
The I learned the WaitRun in FW Clipper uses 100% cpu time and WaitRun in FWH does not use cpu time.
Is there a solution in FW Clipper level or I have the convert the whole systems?
Regards, Euclides

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: WaitRun using 100% processor time
Posted: Wed Dec 21, 2011 03:09 PM
Euclides,

Try this.

Regards,
James


Code (fw): Select all Collapse
//-----------------------------------------------------//
// WaitRun() overrides the FW native function
// The 16 bit version hogs the CPU, this doesn't.
// Author: Sylvain Robert <S.Robert@videotron.ca>
// Date: 2/11/2004

#Define SW_NORMAL 1

FUNCTION Waitrun(cExec,nMode)
  LOCAL nHinstance,nCount, lWaitrun

  DEFAULT nMode := SW_NORMAL

  IF ( nHinstance:= Winexec( cExec, nMode ) ) > 31
    nCount:=GetmoduleUsage( nHinstance )

    DO WHILE GetModuleUsage( nHinstance ) >= nCount
      Waitmessage()
      SysRefresh()
    ENDDO
  ENDIF

  RETURN nHinstance

DLL FUNCTION GetModuleUsage( nProccessid AS _INT ) AS _INT PASCAL LIB "kernel"
//-----------------------------------------------------//
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 159
Joined: Wed Mar 28, 2007 01:19 PM
Re: WaitRun using 100% processor time
Posted: Tue Jan 10, 2012 03:31 PM

Hi james, sorry for the delay (I was out of town :D ).

I remember, some time ago Sylvain has posted something about CPU hog but I could not find it googling. Glad you have it.
Meanwhile I found a similar solution with Timer and the FindWindow function.
Of course, Sylvain´s solution is better.
Thanks and a ´late´ Seasons Greatings.
Regards, Euclides

Continue the discussion