Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to release time to CPU? 1

Status
Not open for further replies.

gadgetguy1111

IS-IT--Management
Mar 19, 2002
20
0
0
SG
Hello,

i'm doing some calculations using nexted for loops.

the structure looks something like this:

for i= 1 to 1000
for j = 1 to 1000
for k = 1 to 1000
do calculations
check for condition
if true exit for
next k
next j
next i

the problem is after a while of running, the program hangs.

i guess this is because win xp thinks the program has failed and will tried to close it.

when i presses ctrl-break, i can see that the program is working ok.

any idea what should i do?

thanks

 
Use "DoEvents" To release time from the app to the CPU

for i= 1 to 1000
for j = 1 to 1000
for k = 1 to 1000
do calculations
check for condition
if true exit for
next k
DoEvents 'maybe here
next j
DoEvents 'maybe here
next i

the placement will depend on how much work you are doing in the loops. Hope this helps. Anything is possible, the problem is I only have one lifetime.
[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top