I'd like to cache the XSLTCompiledTransform object in a Dictionary as I'm having a performance problem with the time it takes to load XSLT from disk.
My question is, am I ok to just add the object into the dictionary without cloning it
When I've done this before in the DNA world I've always had to clone the document but I notice this isn't supported on this object. I also note that the docs state this is thread safe and should be ok.
Any thoughts anyone

XSLTCompiledTransform And Caching
Shivlee
Thread Safety
The XslCompiledTransform object is thread safe once it has been loaded. In other words, after the Load method has successfully completed, the Transform method can be called simultaneously from multiple threads.
If the Load method is called again in one thread while the Transform method is being called in another thread, the XslCompiledTransform object finishes executing the Transform call by continuing to use the old state. The new state is used when the Load method successfully completes.
The Load method is not thread safe when called simultaneously from multiple threads.
If you are talking about Fx 1.1 the XslTransform class must be cloned, or instantiated multiple times if you want to evaluate in a multi-threaded environment.
Regards,
GeorgeMTL
I read the above docs and figured that it must be ok. It just didn't feel correct!
HamidFULL
As stated in the documentation (http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfSystemXmlXslXslTransformClassTopic.asp)
The .Net 1.1 XslTransform IS thread-safe ONLY for transform operations.
Regards,
David Hernandez
ArtSoft
Diego Gonzalez
Lagash Systems SA
C# MVP
LuisGamma
There's also the added complication of it not implementing ICloneable.
crazylikeastraw
And once it's loaded you don't need to clone it before using - Transform() methods are thread safe.