Jump to content

Do Until High CPU utilization


Monolith
 Share

Recommended Posts

Top of the morning to ya.

I have been trouble shooting my script for quite a few hrs now, and i think i have tracked it down to a Do Until statement enclosed in a function.

I had what i thought all the required "sleep(90)" throughout the function but still noticed high cpu utilization when the specific function is called.

Just now i added sleep(90) inside the Do Until statement an it reduced the CPU load by 100% and everything seems to still work.

The issue with high CPU load only happens on XP SP2 machines, so have been trying all the alternatives to get the CPU load down. for the example below i rewrote my entire customized progress-bar using animated .gif and using processsetpriority which some times works in the case of reducing CPU load.

snippet

Func _test123() ;third stage of test123 function
    ProcessSetPriority("test123", 0)
    WinSetState("", "", @SW_MINIMIZE)
    $test123gui = GUICreate("", 233, 119, 452, 349, BitOR($WS_SYSMENU, $WS_DLGFRAME, $WS_POPUP, $WS_CLIPSIBLINGS))
    GUISetBkColor(0x0066CC)
    GUISetState(@SW_SHOW)
    $testlabel = GUICtrlCreateLabel("test123" & @CRLF & "Please Wait...", 0, 0, 255, 75)
    GUICtrlSetFont(-1, 14, 800, 2, "Tekton Pro Ext")
    $bar1 = GUICtrlCreateProgress(12, 80, 209, 33, $PBS_MARQUEE)
    _SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, True, 50)
    GUISetState()
    Do
        Sleep(90)
    Until ProcessExists("test.exe") == 0
    GUICtrlSetData($testlabel, "test123" & @CRLF & "File:" & @CRLF & $file1)
    Sleep(2500)
    GUIDelete($test123gui)
    Sleep(90)
    WinSetState("test123", "", @SW_RESTORE)
    ProcessSetPriority("test123", 1)
EndFunc   ;==>_test123

from anyone's experience, is there any potential side affects from using sleep() inside Do Until? I would be totally wrapped if it stable to do so.

I guess I am just shocked to see CPU load drop from 56-100% to 0% and still work.. for now..

thanks for your time

Edited by Monolith
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...