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 

Make a thread immediately interruptable

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



Joined: 14 May 2006
Posts: 45

PostPosted: Sun May 11, 2008 1:22 pm    Post subject: Make a thread immediately interruptable Reply with quote

I am trying to make the current thread immediately interruptable.

I currently have a work around where I have an msgbox with a timeout of 0.001, but you can still see it flash on the screen.
Back to top
View user's profile Send private message
n-l-i-d
Guest





PostPosted: Sun May 11, 2008 2:06 pm    Post subject: Reply with quote

Purpose? Code?
Back to top
acowbear



Joined: 14 May 2006
Posts: 45

PostPosted: Sun May 11, 2008 2:47 pm    Post subject: Reply with quote

My code works fine with an msgbox, but not at all without it. Here is what I think is occuring. When you click on an altsubmit listview A_GuiControlEvent "I" occures before A_guiControlEvent "Normal", but my code does not work with "I" getting called first, because on "I" a very large number of variables get changed that are needed for the functions that get called on "normal". Therefore I need "normal" to occure before "I". By putting an msgbox, it makes the thread for "I" immediately interruptable, so that "normal" inturrupts "I" and is then able to run its course before "I" messes with it's variables. At least, this is my theory.


Code that doesn't work.
Code:

Gui, 13:Add, ListView, x26 y40 w430 h480 +altsubmit vABook gLVRules, Name|Address

LVRules:
if A_GuiControlEvent=I
{
RUNS A BUNCH OF FUNCTIONS....
}

if (A_GuiControlEvent="Normal" or A_GuiControlEvent="RightClick")
{
RUNS A BUNCH OF Other FUNCTIONS....




Code that works great every time, except that you see an msgbox flash on the screen.
Code:

Gui, 13:Add, ListView, x26 y40 w430 h480 +altsubmit vABook gLVRules, Name|Address

LVRules:
if A_GuiControlEvent=I
{
msgbox,,,problem fixer,0.001
RUNS A BUNCH OF FUNCTIONS....
}

if (A_GuiControlEvent="Normal" or A_GuiControlEvent="RightClick")
{
RUNS A BUNCH OF Other FUNCTIONS....
Back to top
View user's profile Send private message
n-l-i-d
Guest





PostPosted: Sun May 11, 2008 2:54 pm    Post subject: Reply with quote

ListView Documentation wrote:
Also, specifying Critical as the g-label's first line ensures that all "I" notifications are received (otherwise, some might be lost if the script cannot keep up with them).


this?
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 7293
Location: Australia

PostPosted: Mon May 12, 2008 8:25 am    Post subject: Reply with quote

AutoHotkey has to check for window messages while a MsgBox is visible for the MsgBox to respond to user input. You may try using Sleep -1 instead:
Quote:
"Sleep -1": A delay of -1 does not sleep but instead makes the script immediately check its message queue. This can be used to force any pending interruptions to occur at a specific place rather than somewhere more random. See Critical for more details.
Back to top
View user's profile Send private message Visit poster's website
acowbear



Joined: 14 May 2006
Posts: 45

PostPosted: Mon May 12, 2008 9:54 pm    Post subject: Reply with quote

Thanks for the help!
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