Unity error "is inaccessible due to its protection level"

I totally understand that I need to instantiate prefabs before using and so on, however, I am now getting such an “inaccessible” error with a Class of the C# collection.

I try to use a ConcurrentQueue (System.Collections.Concurrent.ConcurrentQueue) and the code looks like this:

using System.Collections.Concurrent;
using UnityEngine;
using System.Threading;

public class Agent : MonoBehaviour {
    static private ConcurrentQueue<Storage> tasks = new ConcurrentQueue<Storage>();

Although the docs list “ConcurrentQueue” Unity keeps saying:
“System.Collections.Concurrent.ConcurrentQueue is inaccessible due to its protection level”

How can I use it? Why does Unity complain at all, since the class is supplied by System.Collections.Concurrent?

The mono framework doesn’t seem to have a ConcurrentQueue class in it’s mscorlib while the .NET framework does have one. There is one that is declared as internal class inside the “nunit.framework”. It’s possible that your IDE might recognise that class but isn’t allowed to access it since it’s an internal class.

Though you might be able to just copy the reference source into your project. As alternative you could roll your own implementation.

ps: Just in case you don’t know: Most parts of the Unity API is not thread-safe and is not allowed being used from another thread than the main thread.