Is reading from an XmlDocument object thread safe?

前端 未结 4 788
逝去的感伤
逝去的感伤 2020-12-11 08:08

I was wondering if i could safely read from an XmlDocument object using SelectNodes() and SelectSingleNode() from multiple threads with no problems. MSDN says that they are

4条回答
  •  悲&欢浪女
    2020-12-11 08:20

    As you are going to write/read to/from the XML document you need to synchronize those two operations if you don't want to run into race conditions. And if you care about performance (who doesn't?) a ReaderWriterLockSlim might perform better than locking.

提交回复
热议问题