Re: Timer / Thread and COM / JScript
"Alexander Adam" <contact@emiasys.com> wrote in message
news:1173024129.639627.171710@8g2000cwh.googlegroups.com
I am building a JScript host within an ATL ActiveX.
Now I wanted to implement the setTimeout function. Due the heavy load
of WM_TIMER messages I've wanted to use Multimedia Timers
(timerSetEvent etc.) which are running in their own thread. But
whenever I try to invoke my custom function within JScript after the
timer fired, I get an E_UNEXPECTED which I guess comes from calling
from the wrong thread.
There are very few things you can safely do from timeSetEvent callback.
See the documentation on TimeProc:
"Applications should not call any system-defined functions from inside a
callback function, except for PostMessage, timeGetSystemTime,
timeGetTime, timeSetEvent, timeKillEvent, midiOutShortMsg,
midiOutLongMsg, and OutputDebugString."
Consider posting a user-defined message to your window, and call the
script function from that handler.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925