AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Temporarily suspend a function

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ribbs2521



Joined: 28 Sep 2007
Posts: 273
Location: New York

PostPosted: Fri Jan 08, 2010 4:17 pm    Post subject: Temporarily suspend a function Reply with quote

I'm sorry if I went about this the wrong way, this is essentially a continuation of a previous post but because it's no longer about the Critical command I wanted to make the title reflect the current topic which is why, when I "suspend" the function, it doesn't start back up.

the original thread is here (I've copied over the pertinent information)
http://www.autohotkey.com/forum/viewtopic.php?p=322691#322691

The timed sub runs every 10 seconds, if I run the manual one in between then it does suspend the next timed one. The problem is that when I click OK on the Query in process message from the manual sub, the program stays stuck in a while loop from the timed routine. It's like, the timed routine took priority and until it finishes then the manual one won't start again.

Here is what you can do to test and see what I see, run the program and
wait 10 seconds....
MESSAGE: gonna run and inQuery is ><
Click OK
MESSAGE: Query In Process (From the Timed Call)
Click OK
MESSAGE: Ran Timed Routine
Click OK
Press F4 to start the manual routine
MESSAGE: Query In Process (From the F4 call)
....leave the msgbox open and wait for timed routine to run again....
MESSAGE: gonna run and inQuery is >1<
Click OK
Nothing happens (GOOD, timed routine suspended)
Click OK on the Query In Process (remember: that one is from the manual, so it should finish the manual and unsuspend the timed)

then nothing happens... when I opened the debugger it shows it looping in the timed routine's while loop and inQuery is still 1, the manual routine never changed the value back to 0 and didn't get the message at the end of the manual routine.


Here is the code
Code:
SetTimer, TimedRoutine, 10000


F4::
  querytest()
  msgbox, inQuery is >%inQuery%<
  return


TimedRoutine:
  msgbox, gonna run and inQuery is >%inQuery%<
  querytest()
  msgbox, Ran Timed Routine
  return


querytest()
{
  global inQuery

  While (inQuery) {
  }
  inQuery := 1
  Msgbox, Query In Process
  inQuery := 0

}
Back to top
View user's profile Send private message
Peter



Joined: 30 Dec 2005
Posts: 448

PostPosted: Sat Jan 09, 2010 8:19 am    Post subject: Reply with quote

Is that the complete code? Because you do nothing in the While loop (or elsewhere) that can exit the loop with variable inQuery.
You can never get out of your While loop :
Code:
While (inQuery) {
   ; doing nothing!
  }
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group