Jump to content

Leaving a program idle for a long time


Recommended Posts

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!

Link to comment
Share on other sites

  • Moderators

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
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
 Share

×
×
  • Create New...