/// <summary>
        /// Locks a couple of UsableWriteLocks for Writing in order to prevent deadlocks.
        /// </summary>
        /// <param name="locks">the WriteLocks to lock</param>
        /// <returns>a multidisposer to release the locks in opposite order</returns>
        public static MultiDisposer LockWrite(params UsableWriteLock[] locks)
        {
            IDisposable[]     disposables = new IDisposable[locks.Length];
            UsableWriteLock[] lockys      = new UsableWriteLock[locks.Length];

            for (int i = 0; i < locks.Length; i++)
            {
                int currentIndex = -1;

                for (int j = 0; j < locks.Length; j++)
                {
                    if (lockys.Contains(locks[j]))
                    {
                        continue;
                    }

                    if (lockys[i] == null)
                    {
                        currentIndex = j;
                    }
                    else if (lockys[i].ID < locks[j].ID)
                    {
                        currentIndex = j;
                    }
                }

                lockys[i]      = locks[currentIndex];
                disposables[i] = locks[currentIndex].LockWrite();
            }

            return(new MultiDisposer(disposables));
        }