Concurrent bidirectional dictionary I've been agonizing over this for an hour or two. I require a bidirectional dictionary that was thread safe. From what I understand about dictionaries, they're thread safe when being read from, but no so much when being written to. I've tried to write this code snippet to my understanding of correct, but a review would be excellent if possible.

class ConcurrentBidirectionalDictionary&lt;TKey,UKey&gt;
{
    private Dictionary&lt;TKey, UKey&gt; BackingDictionary;

    public ConcurrentBidirectionalDictionary()
    {
        BackingDictionary = new Dictionary&lt;TKey, UKey&gt;();
    }

    //Adding to dictionaries is not thread-safe ergo, lock when adding
    private readonly object _SyncLock = new object();
    public void Add(TKey item1, UKey item2)
    {
        if (!BackingDictionary.ContainsKey(item1) &amp;&amp; !BackingDictionary.ContainsValue(item2))
        {
            lock (_SyncLock)
            {
                if (!BackingDictionary.ContainsKey(item1) &amp;&amp; !BackingDictionary.ContainsValue(item2))
                {
                    BackingDictionary.Add(item1, item2);
                }
                else
                {
                    ThrowNewDuplicateKeyException(item1, item2);
                }
            }
        }
        else
        {
            ThrowNewDuplicateKeyException(item1, item2);
        }
    }

    private void ThrowNewDuplicateKeyException(TKey item1, UKey item2)
    {
        if (BackingDictionary.ContainsKey(item1) &amp;&amp; BackingDictionary.ContainsValue(item2))
        {
            throw new ArgumentException("Duplicate Keys not allowed", "item1, item 2", null);
        }
        else if (BackingDictionary.ContainsKey(item1))
        {
            throw new ArgumentException("Duplicate Keys not allowed", "item1", null);
        }
        else if (BackingDictionary.ContainsValue(item2))
        {
            throw new ArgumentException("Duplicate Keys not allowed", "item 2", null);
        }
    }

    //Reading is thread safe, no lock needed
    public TKey GetFromUKey(UKey UKey)
    {
        var Record = BackingDictionary.FirstOrDefault(x =&gt; EqualityComparer&lt;UKey&gt;.Default.Equals(x.Value, UKey));
        if (Record.Equals(default(KeyValuePair&lt;TKey,UKey&gt;)))
        {
            throw new IndexOutOfRangeException($"Unable to find UKey {UKey}");
        }
        return Record.Key;
    }

    public UKey GetFromTKey(TKey TKey)
    {
        return BackingDictionary[TKey];
    }
}
It is better to use CouncurrentDictionary to reduce lock contention:

class Map&lt;X, Y&gt;
{
    public X this[Y y]
    {
        get { return YX[XY[YX[y]]]; } // Ensure Set completion
        set { Set(value, y); }
    }

    public Y this[X x]
    {
        get { return XY[x]; }
        set { Set(x, value); }
    }

    void Set(X x, Y y)
    {
        if (!YX.GetOrAdd(y, x).Equals(x))
            throw new InvalidOperationException();

        if (!XY.GetOrAdd(x, y).Equals(y))
            throw new InvalidOperationException();
    }

    ConcurrentDictionary&lt;X, Y&gt; XY { get; } = new ConcurrentDictionary&lt;X, Y&gt;();
    ConcurrentDictionary&lt;Y, X&gt; YX { get; } = new ConcurrentDictionary&lt;Y, X&gt;();
}