WaitRun using 100% processor time

Post Reply
User avatar
Euclides
Posts: 144
Joined: Wed Mar 28, 2007 1:19 pm

WaitRun using 100% processor time

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: WaitRun using 100% processor time

Post 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"
//-----------------------------------------------------//
 
User avatar
Euclides
Posts: 144
Joined: Wed Mar 28, 2007 1:19 pm

Re: WaitRun using 100% processor time

Post 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
Post Reply