(Created page with "This page aims to discuss threads in mIRC, delayed execution and non blocking while loop. == Thread == There are no thread in mIRC, mIRC is single threaded, always. Sometim...") |
(→mIRC's message loop) |
||
Line 12: | Line 12: | ||
For each iteration of the loop, one message only is processed and then the loop repeats. | For each iteration of the loop, one message only is processed and then the loop repeats. | ||
− | This approach is what allows | + | This approach is what allows mIRC, or scripters to create the thread illusions. |
== Nested call to the message loop == | == Nested call to the message loop == |
Revision as of 09:38, 9 June 2018
This page aims to discuss threads in mIRC, delayed execution and non blocking while loop.
Thread
There are no thread in mIRC, mIRC is single threaded, always.
Sometimes it looks like mIRC can do multiple things at the same time without freezing, this is never the case, below we will discuss the different illusions that can occur.
mIRC's message loop
mIRC, just like many Windows applications, is based on a loop which processes messages, messages correspond to some kind of event, new data on a socket, a click on a button etc. For each iteration of the loop, one message only is processed and then the loop repeats.
This approach is what allows mIRC, or scripters to create the thread illusions.
Nested call to the message loop
The trick is to "call" the message loop yourself, handling one more message before returning to handling the current message
$input
mIRC itself, with $input, does this:
alias test {
echo -a 1
noop $input(text,e)
echo -a 2
}
When you call /test, the scripting engine has to wait for your input before processing the rest of the code, just waiting for your input would freeze mirc since no others messages are processed while one message is processed, in normal time, so mIRC itself call the message loop and process some of the messages,