Windows Script Hosts

When implementing Microsoft Windows Script host, you can safely assume that a scripting engine only calls the IActiveScriptSite interface in the context of the base thread as long as the host does the following:

  • Chooses a base thread (generally the thread that contains the message loop).

  • Instantiates the scripting engine in the base thread.

  • Calls scripting engine methods only from the base thread, except where specifically allowed, as in the cases of IActiveScript::InterruptScriptThread and IActiveScript::Clone.

  • Calls the scripting engine's dispatch object only from the base thread.

  • Ensures that the message loop runs in the base thread if a window handle is provided.

  • Ensures that objects in the host's object model only source events in the base thread.

    These rules are automatically followed by all single-threaded hosts. The restricted model described above is intentionally loose enough to allow a host to abort a stuck script by calling IActiveScript::InterruptScriptThread from another thread (initiated by a CTRL+BREAK handler or the like), or to duplicate a script in a new thread using IActiveScript::Clone.

Remarks

None of these restrictions apply to a host that chooses to implement a free-threaded IActiveScriptSite interface and a free-threaded object model. Such a host can use the IActiveScript interface from any thread, without restriction.

See also

Windows Script Interfaces