Jump to content

Recommended Posts

Posted

What am I supposed to do, if a program is able for a long time?

My program is idle for 20 minutes, before doing a very tiny task, and then starting all over again.

I tries using Sleep(), but that literally melts my CPU and pushes them up for 20 to 30%. Permanently checking the time costs too much CPU too.

Any other way of doing this? Preferably without taking more than 1% CPU. It also needn't be exactly 20 minutes, everything between 15 and 25 is fine too :D

Thanks!

  • Moderators
Posted

Wicked_Caty,

I run many AutoIt executables that stay idle for long periods - and none of them use any CPU. It sounds as if you have a tight loop while idling which is using up cycles - try adding a Sleep(10) inside the loop. Or post the code you use and we can see exactly how to deal with the problem.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

Wicked_Caty,

I think the problem is in line....

Oh, wait, have not seen the code.

kylomas

edit: Shit, there goes M23 and his bionic fingers...

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted (edited)

Wicked_Caty,

Your code doesn't do anything...

Func Reminder0()

   While 1

      Sleep(20000)
      SoundPlay(@AppDataCommonDir + "\rem\sound.mp3")

   WEnd

EndFunc

Func Reminder1()

   While 1

      ; variable t0 for desired time
      ; calculation for variable t1 for desired time <--- know how to do that, but this is just an example

      While Not $t0 = $t1

         SoundPlay(@AppDataCommonDir + "\rem\sound.mp3")
         ExitLoop()

      WEnd

   WEnd

EndFunc

kylomas

edit: ExitLoop is not a function, it is a statement.  Please post a runnable reproducer.

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

That's not the whole code. And the whole code doesn't matter. That are only the two ways that I've figured out put into two functions. It's about the part within the functions, but what's written outside of it. And it would do something if you add those silly two lines outside of the functions and declare the variables $t0 and $t1

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
×
×
  • Create New...