Page 1 of 1

WaitRun using 100% processor time

Posted: Tue Nov 22, 2011 11:48 am
by Euclides
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

Re: WaitRun using 100% processor time

Posted: Wed Dec 21, 2011 3:09 pm
by James Bott
Euclides,

Try this.

Regards,
James

Code: Select all

//-----------------------------------------------------//
// 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"
//-----------------------------------------------------//
 

Re: WaitRun using 100% processor time

Posted: Tue Jan 10, 2012 3:31 pm
by Euclides
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