Choosing a Threading Model
There are two versions of the XML control.
rental model
The rental model version is designed for single-threaded access. To use the rental model control provided with MSXML 6.0, use the Microsoft.DOMDocument.6.0
progID.
free-threaded model
The free-threaded model version is designed for multiple thread access. To use the free-threaded control provided with MSXML 6.0, use the Microsoft.FreeThreadedDOMDocument.6.0
progID.
Note
In MSXML, "free-threaded" means ThreadingModel='Both'
, and cross-thread marshalling is supported.
If you plan for several threads to access your XML data from a single control, be sure to use the free-threaded control. If only one thread will access the XML data, use the rental model control for better performance.
The following is a sample global.asa file that creates session-level and application-level free-threaded versions of the XML control.
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
ON error RESUME next
SET Application("AppFXMLdoc") = _
server.CreateObject("Msxml2.FreeThreadedDOMDocument.6.0")
SET Session("SessFXMLdoc") = _
server.CreateObject("Msxml2.FreeThreadedDOMDocument.6.0")
End Sub
Sub Session_OnEnd
ON error RESUME next
SET Session("SessFXMLdoc") = nothing
SET Application("AppFXMLdoc") = nothing
Session("SessFXMLdoc") = empty
Application("AppFXMLdoc") = empty
End Sub
</SCRIPT>
Scripts accessing the Session
and Application
objects will be able to simultaneously access the AppFXMLdoc
and SessFXMLdoc
objects.