From WikiChip
mirc/thread
< mirc
Revision as of 09:35, 9 June 2018 by Ouims (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 different parties to create 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,