Sign in to follow this  
Followers 0
arielsa

Program Using To Much Cpu

4 posts in this topic

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()

Share this post


Link to post
Share on other sites



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 ...


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thank you both, i see now that it was an older version of the code that i was running.

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