I'm trying to include the following line in my C# code, but for some reason it's being marked as an error:
public SynchronizedCollection<Uri> allImages = new SynchronizedCollection<Uri>();
I've tried including using System.Collections.Generic
but it does not resolve the issue. Any idea how I can get a SynchronizedCollection<T>
working in my application?
The synchronizedCollection () method of java.util.Collections class is used to return a synchronized (thread-safe) collection backed by the specified collection. In order to guarantee serial access, it is critical that all access to the backing collection is accomplished through the returned collection.
The SynchronizedCollection<T> stores data in a List<T> container and provides an object that can be set and used to synchronize access to the collection so that it is thread-safe. The IList<T> container can be recovered using the Items property. The synchronized object can be recovered using the SyncRoot property.
Generic System. Collections. Generic Provides a thread-safe collection that contains objects of a type specified by the generic parameter as elements. The type of object contained as items in the thread-safe collection. System. Collections. Generic. Synchronized Keyed Collection<K,T> System. Service Model. Dispatcher. Channel Dispatcher Collection
Synchronized Keyed Collection<K,T> System. Service Model. Dispatcher. Channel Dispatcher Collection System. Service Model. Extension Collection<T> The SynchronizedCollection<T> stores data in a List<T> container and provides an object that can be set and used to synchronize access to the collection so that it is thread-safe.
If you look at the documentation you will see it states
Namespace: System.Collections.Generic
Assembly: System.ServiceModel (in System.ServiceModel.dll)
This means that although it is in the System.Collections.Generic
namespace you need to make sure you have the System.ServiceModel.dll
dll included in your project as a refrence to be able to use the class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With