Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I use SynchronizedCollection when I include System.Collections.Generic?

Tags:

c#

.net

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?

like image 910
shiitake_the_mushroom Avatar asked Jun 18 '16 23:06

shiitake_the_mushroom


People also ask

What is synchronized collection in Java?

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.

What is the difference between IList and synchronizedcollection in Java?

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.

What is system generic collection in Java?

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

What is synchronized keyed collection in service model?

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.


1 Answers

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.

like image 67
Scott Chamberlain Avatar answered Nov 15 '22 08:11

Scott Chamberlain