NameValueCollection missing SyncRoot???

  • Thread starter Thread starter Wayne Brantley
  • Start date Start date
W

Wayne Brantley

In trying to make some parts of a NameValueCollection threadsafe, the docs
say use a property called SyncRoot, which is inherited form
NameObjectCollectionBase.

However, there is no such object...

NameValueCollection temp = new NameValueCollection();

temp.SyncRoot ???
 
Hi Wayne,

NameValueCollection and NameObjectCollectionBase classes do not provide
thread safe wrappers; you would need to create your own.
Secondly, SyncRoot property in the NameObjectCollectionBase is an explicit
implementation of ICollection.SyncRoot. So, cast your object to ICollection
to access the same
((ICollection)temp).SyncRoot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top