Jump to content

Program Using To Much Cpu


Recommended Posts

Hi all, I've written a program that shutdown the computer on specified times it receives from a server. (the program gives two warnings before shutting down). somehow the program uses the CPU all the time at about 15%, even when it supposed to be at "sleep" mode.

Is it normal? is there something that can be done about it?

Here is the code, thanks for helping.

Func remote_sd()
    Dim $SD_First_Warn
    Dim $LastRead = 0000
    Dim $CurrentTime
    Dim $SD_Hour, $SD_Minute, $SD_Warning
    Dim $ini_location = ''
    Dim $first_warn_time_to_show
    
    $ini_location = IniRead($ini_location, "param", "ini_location", "\\server\ShutDown\sd.ini")
    While 1
    
        $CurrentTime = TimerInit()
        If ($CurrentTime - $LastRead) > 1800000 Then
            $SD_First_Warn = IniRead($ini_location, "param", "first_warn", "5")                                                         
            $SD_Hour = IniRead($ini_location, "param", "hour", "19")                                                            
            $SD_Minute = IniRead($ini_location, "param", "Minute", "0")
            $SD_Warning = IniRead($ini_location, "param", "time_to_warn", "30")
            $first_warn_time_to_show = IniRead($ini_location, "param", "first_warn_time_to_show", "30")
            $LastRead = TimerInit()
        EndIf
        Sleep(120000)
        if ((@HOUR >= $SD_Hour) And (@MIN > $SD_Minute)) Then
            $message = (@LF & "This Computer will Shutdown in " & $SD_First_Warn & " Minutes.")
            SplashTextOn("Computer ShutDown", $message , 300, 70, 350, 1, 16)
            sleep($first_warn_time_to_show)
            SplashOff()
            ExitLoop
        EndIf
    WEnd
    Sleep($SD_First_Warn * 60000)
    $message = @LF & "Shutting down in"
    SplashTextOn("Computer ShutDown", $message , 300, 70, 350, 1, 16)
    For $x = 0 to $SD_Warning
          $y = $SD_Warning-$x
        ControlSetText("Computer ShutDown", $message, "Static1", $message &" "& $y &" Seconds")
        sleep(1000)
    Next
    If  @WDAY <> 4 then
        ShutDown(13)
    Else
        ShutDown(7)
    EndIf
EndFunc
opt("TrayIconHide", 1)
remote_sd()
Link to comment
Share on other sites

  • Developers

Hi all, I've written a program that shutdown the computer on specified times it receives from a server. (the program gives two warnings before shutting down). somehow the program uses the CPU all the time at about 15%, even when it supposed to be at "sleep" mode.

Is it normal? is there something that can be done about it?

Here is the code, thanks for helping.

Doesn't use any CPU here while waiting ...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...