mIRC Homepage
Posted By: FroggieDaFrog Weird timer+com issue - 18/03/17 02:26 AM
I'm not sure how else to explain this than to show it as code:

Code:
alias -l addjs {
  bset -t &example $calc(1 + $bvar(&example,0)) $1-
}
alias example {
  addjs example=function(){
  addjs     var request = new ActiveXObject('MSXML2.SERVERXMLHTTP.6.0');
  addjs     request.open('GET', 'https://forums.mirc.com/ubbthreads.php/forum_summary', true);
  addjs     request.send();
  addjs     request.waitForResponse(60);
  addjs     if (request.readyState == 4) return "Done";
  addjs     request.abort();
  addjs     return "Timeout";
  addjs };

  var %js = example()

  comopen example MSScriptControl.ScriptControl
  echo -a Language: $com(example, language, 4, bstr, jscript)
  echo -a JS Load : $com(example, ExecuteStatement, 1, &bstr, &example)

  .timer -iom 1 0 echo -a Timer Triggered

  echo -a Calling function
  echo -a Called: $com(example, eval, 1, bstr, %js) $com(example).result

  comclose example
}


When the script is executed, the timer triggers while mIRC is waiting for the com to return:
Code:
* Opened Com 'example' (MSScriptControl.ScriptControl)
-
Language: 1
JS Load : 1
Calling function
Timer Triggered
Called: 1 Done
-
* Closed Com 'example'
Posted By: Khaled Re: Weird timer+com issue - 18/03/17 10:03 AM
I changed the URL to use a website with a large, slow loading page, added a long-running while loop (to freeze mIRC) after the final $com() call, and then ran the alias.

The first thing I noticed is that I can type into the status window editbox during the slow $com() call. The moment the $com() call returns, the while loop runs and freezes mIRC. This seems to indicate that the COM object itself is causing Windows messages to be dispatched to mIRC while the COM object is waiting for the website to reply. As the mIRC /timer uses Windows messages, it is being triggered.
© mIRC Discussion Forums