Forum Xamarin.Forms


I need to use a thread safe List. I was hoping to use the BlockingCollection in System.Collections.Concurrent but it does not seem to be available in Xamarin Forms PCL (targeting 4.5, iOS, Android & WinPhone).

Can anyone help. System.Collections.Concurrent is not an available reference.

Thanks in advance


  • MihaMarkicMihaMarkic SI ✭✭✭✭

    I think that's because that namespace isn't implemented for Windows Phone Silverlight (it is in native 8.1 though).
    Try this instead (never tried).

  • PaulFitzpatrickPaulFitzpatrick GBMember ✭✭

    According to Xamarin API documentation this namespace should be available (

    Can somebody enlighten me on how to access it so that I don't need to write my own or implement the solution above.

    Miha - what do you mean exactly when you say "it's native in 8.1 though"? Should I be able to target 8.1 and therefore get the namespace across all mobile platforms (this is a Xamarin Forms project).

    Thanks again..

  • MihaMarkicMihaMarkic SI ✭✭✭✭

    @PaulFitzpatrick‌ Yes, that's the case. But then I am not sure about how well does Xamarin support Windows Phone 8.1 native (not Silverlight).
    Note also that there is a ConcurrentDictionary implemented in Xamarin.Forms.Core (Xamarin.Forms.ConcurrentDictionary<TKey, TValue>) regardless of target platform.

  • MarkErickson.91MarkErickson.91 USMember ✭✭

    @MihaMarkic‌ I have Xamarin.Forms (seems to be latest) but I'm not seeing ConcurrentDictionary implemented in there. Am I missing something?

  • MihaMarkicMihaMarkic SI ✭✭✭✭

    @Sparky91‌ Looks like it is internal for some reason. I am almost sure I could create in pre3. Hm.


    Sorry for necroing an old post but I'm encountering the same issue and see now resolution.

    I'm getting this on the SQLite file recommended here:

    Can't compile due to this error along side a missing reference for DllImport.

    That project is already including the SQLite.Net-PCL and System.Data.SQLite packages.

  • GeoffArmstrongGeoffArmstrong CAMember ✭✭

    What I did for a concurrent queue when I needed one was basically this:

    I declared a common type in the PCL:

        public interface IPclProducerConsumerCollection<T> {
            bool TryAdd(T item);
            bool TryTake(out T item);

    Then I added a get method to my platform-specific stuff:

        public interface IPlatformSpecific {
            // ...
            IPclProducerConsumerCollection<T> GetConcurrentQueue<T>();
            // ...

    And then on iOS and Android I implemented it by subclassing the existing ConcurrentQueue<T>:

        public class PclConcurrentQueue<T> : ConcurrentQueue<T>, IPclProducerConsumerCollection<T> {
            public bool TryAdd(T item)
                return ((IProducerConsumerCollection<T>)this).TryAdd(item);
            public bool TryTake(out T item)
                return ((IProducerConsumerCollection<T>)this).TryTake(out item);
        public class IosPlatformSpecific : IPlatformSpecific {
            // ...
            public IPclProducerConsumerCollection<T> GetConcurrentQueue<T>()
                return new PclConcurrentQueue<T>();
            // ...

    This allowed me to use System.Collections.Concurrent.ConcurrentQueue<T> on my different platforms even though it doesn't exist in the PCL.

  • Chris.3704Chris.3704 USUniversity ✭✭

    I'm using Xamarin 3.11 and I can now work with the ConcurrentQueue class by using the System.Collections.Concurrent namespace.

  • RizkyNugrohoRizkyNugroho IDMember ✭✭

    I resolved this by changing the PCL Profile to PCL 4.5 - Profile111. Open Option from PCL Project > General > General


  • RLittlesIIRLittlesII USMember ✭✭

    @RizkyNugroho said:
    I resolved this by changing the PCL Profile to PCL 4.5 - Profile111. Open Option from PCL Project > General > General


    This worked for me. Thanks!!!

Sign In or Register to comment.