Jump to content

Return to While loop


Recommended Posts

Hi all!

I'm struggling with my code:

I have 

HotKeySet("{F1}", "_Suspend")

While 1
    _MainFunc()
WEnd

Func _MainFunc()
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $B_Class
                _ClassCreation()
            Case $B_Registry
                _RegistryUpdate()
        EndSwitch
endFunc()

Func _suspend()
    _resetClassConditions()
    _resetVars()
    _resetArrays()
    Return _Mainfunc()
EndFunc

That means program will run until F1 is pressed.

Once pressed I hoped to instantly suspend all activities but, on the contrary, if there is a running activity on _registryUpdate() this activity is performed, no matter if I used F1 to stop it.

Question, generally, is: is there a way to completely exit to main while loop stopping ALL running activities?

Thanks, if you need further details let me know,

Marco

Link to comment
Share on other sites

2 hours ago, marko001 said:

Question, generally, is: is there a way to completely exit to main while loop stopping ALL running activities?

No.

Statements are atomic withing Autoit, all the various psuedo out-of-band mechanisims, HotKeySet, Adlib, callbacks, will not interrupt an executing statement and wrest control.  The only statement that has an exception I'm aware of is Sleep().

Therefore, you can try to make whatever statement that has control execute quicker, or use Run to start another process in the background and have your main program loop until its finished.  

Code hard, but don’t hard code...

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