Esempio n. 1
0
        public static void Create(Database database, string name)
        {
            if (database == null)
                throw new ArgumentNullException("database", "database is null.");
            if (name == null)
                throw new ArgumentNullException("name", "name is null.");
            if (Exists(database, name))
                throw new ArgumentException(string.Format("Queue with the name \"{0}\" already exists.", name), "name");

            var queue = new Queue(name);
            queue.QueueLock.EnterWriteLock();
            try
            {
                database.QueuesLock.EnterWriteLock();
                try
                {
                    database.QueueNames.Add(queue.Name, queue.Id);
                    database.Queues.Add(queue.Id, queue);
                }
                finally
                {
                    database.QueuesLock.ExitWriteLock();
                }
            }
            finally
            {
                queue.QueueLock.ExitWriteLock();
            }
        }