VB Sleep Hangs up CPU 
Author Message
 VB Sleep Hangs up CPU

I wrote a program that uses the Sleep call in
VB.  When the program goes to sleep the CPU is
delayed.  If I try to open an excel sheet while
it is sleeping it takes about 3 minuets to open
the sheet.  Here's an example of the code

do

do the events

sleep X milliseconds

loop

This program is designed to always run in the
background of a PC and peroidicly wake up and
check for things.  I am closing all connections
to a database before going to sleep.  On average
this program sleeps for 5 or 10 minuites.  I am
experiencing this delay in my CPU performance
when this program is on.  Every program is
delayed when my program is running.  PLEASE
HELP!!!!!

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sat, 24 Aug 2002 03:00:00 GMT  
 VB Sleep Hangs up CPU

?I wrote a program that uses the Sleep call in
?VB.  When the program goes to sleep the CPU is
?delayed.  If I try to open an excel sheet while
?it is sleeping it takes about 3 minuets to open
?the sheet.  Here's an example of the code
?
?do
?
?do the events
?
?sleep X milliseconds
?
?loop
?
?This program is designed to always run in the
?background of a PC and peroidicly wake up and
?check for things.  I am closing all connections
?to a database before going to sleep.  On average
?this program sleeps for 5 or 10 minuites.  I am
?experiencing this delay in my CPU performance
?when this program is on.  Every program is
?delayed when my program is running.  PLEASE
?HELP!!!!!

Every program or just those like Excel, Access, Word, etc., that
make use of VBA?  You might try something like this:

==========
   'for a 5 minute Sleep
   Dim lngI As Long
   For lngI = 1 To 300  '300 1-second Sleeps
      Sleep (1000)
   Next lngI
==========

Worth a shot.

--
Paul Marshall



Sat, 24 Aug 2002 03:00:00 GMT  
 VB Sleep Hangs up CPU
it's not an exact amount of time, but if that's not necessary, this might
help.

public function Delay(HowLong as single)
    dim starttime as single
    starttime=timer
    do until timer-starttime>=howlong
        doevents
    loop
end function

then call it like this:
call Delay(300)

this will delay the program for 300 seconds (5 minutes), but not stall
anything.

I wrote a program that uses the Sleep call in
VB.  When the program goes to sleep the CPU is
delayed.  If I try to open an excel sheet while
it is sleeping it takes about 3 minuets to open
the sheet.  Here's an example of the code

do

do the events

sleep X milliseconds

loop

This program is designed to always run in the
background of a PC and peroidicly wake up and
check for things.  I am closing all connections
to a database before going to sleep.  On average
this program sleeps for 5 or 10 minuites.  I am
experiencing this delay in my CPU performance
when this program is on.  Every program is
delayed when my program is running.  PLEASE
HELP!!!!!

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 24 Aug 2002 03:00:00 GMT  
 VB Sleep Hangs up CPU
I have experimented with timers.  Short timers looping is OK but the type of
timer you are trying to setup does exactly what you are complaining about.
Sleep is not a good command to use for long term timing.

I have an app that is on a PC running in the background.  It is looking for
MS Games every
two seconds.  Does not take up CPU processing.  I am using the VB Timer.
Works great and
does not pull the CPU down.

Check http://www.vb-helper.com  sample code and for longtime.  Rod Stephens

Bob Askey

Quote:

> I wrote a program that uses the Sleep call in
> VB.  When the program goes to sleep the CPU is
> delayed.  If I try to open an excel sheet while
> it is sleeping it takes about 3 minuets to open
> the sheet.  Here's an example of the code

> do

> do the events

> sleep X milliseconds

> loop

> This program is designed to always run in the
> background of a PC and peroidicly wake up and
> check for things.  I am closing all connections
> to a database before going to sleep.  On average
> this program sleeps for 5 or 10 minuites.  I am
> experiencing this delay in my CPU performance
> when this program is on.  Every program is
> delayed when my program is running.  PLEASE
> HELP!!!!!

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 24 Aug 2002 03:00:00 GMT  
 VB Sleep Hangs up CPU

Quote:
> public function Delay(HowLong as single)
>     dim starttime as single
>     starttime=timer
>     do until timer-starttime>=howlong
>         doevents
>     loop
> end function

> then call it like this:
> call Delay(300)

> this will delay the program for 300 seconds (5 minutes), but not stall
> anything.

If you run your example just before midnight, it'll delay forever because
the timer function resets to zero at midnight.  Be careful not to use
something like your example in a real program.  I call this the "Gremlins"
bug. :-)

-- Roger
  Harry Nilsson Web Pages: http://www.jadebox.com/nilsson/



Sun, 25 Aug 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. VB Sleep is causing the CPU to Hang!

2. Outlook Hang ups

3. Visual Voice and Hang-ups

4. Reducing Load on CPU in Access - Sleep API?

5. Sleep API is using up 60% CPU time in the DLL

6. HOW to wait or sleep to free CPU time

7. wscript.sleep uses 100% CPU

8. IDE Hangs/Pauses/Sleeps/Freezes ???

9. activeX-dll hangs with 99% cpu-time

10. dllHost hangs with 99% cpu time

11. activeX-dll hangs with 99% cpu-time

12. wscript.sleep 1 and wscript.sleep 2

 

 
Powered by phpBB® Forum Software