Sign in to follow this  
Followers 0
silver217

do sleep until file exists ?

5 posts in this topic

I am experiencing heavy cpu load with this:

do

sleep(1000)

until FileExists('d:\aaa.log')

is there a smarter way ?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I am experiencing heavy cpu load with this:

do

sleep(1000)

until FileExists('d:\aaa.log')

is there a smarter way ?

of course it depends in the structure of the rest of your code but anyway i always try to avoid Do..Until, maybe this:

While 1
    If FileExists('d:\aaa.log') Then ExitLoop
WEnd
Edited by Gif

Share this post


Link to post
Share on other sites

of course it depends in the structure of the rest of your code but anyway i always try to avoid Do..Until, maybe this:

While 1
    If FileExists('d:\aaa.log') Then ExitLoop
WEnd
Thanks for your reply,

Your suggestion gives here the same problem, maybe it is my computer only,

but I don't know how to start resolving it.

I wrote two test programs:

Do

sleep(1000)

until fileexists('G:\aaa.txt')

Exit

and

While 1

if fileexists('G:\bbb.txt') then ExitLoop

WEnd

Exit

when I start the Process Explorer (ctrl-alt-del) then both programs

show 95 to 99% CPU load.

Anybody who can help me with this ?

Share this post


Link to post
Share on other sites

Put Sleep(1) or Sleep(100) between each check.

Share this post


Link to post
Share on other sites

I am experiencing heavy cpu load with this:

do

sleep(1000)

until FileExists('d:\aaa.log')

is there a smarter way ?

There is nothing wrong with your method.

You can try changing the Sleep() time but your code gives me a 0 CPU usage in task manager

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0