/// <summary> /// Attempts to add new item to processing queue /// </summary> /// <param name="element">New item</param> /// <param name="timeout">Adding timeout in milliseconds</param> /// <param name="token">Cancellation token</param> /// <returns>True if item was added, otherwise false</returns> /// <exception cref="ObjectDisposedException"></exception> /// <exception cref="InvalidOperationException"></exception> public override bool Add(T element, int timeout, CancellationToken token) { CheckDisposed(); if (IsAddingCompleted) { throw new InvalidOperationException("Adding was completed for QueueAsyncProcessor: " + this.Name); } var result = _queue.TryAdd(element, timeout, token); if (Profiling.Profiler.IsProfilingEnabled) { if (result) { Profiling.Profiler.QueueAsyncProcessorElementCountIncreased(this.Name, ElementCount, QueueCapacity); } else { Profiling.Profiler.QueueAsyncProcessorElementRejectedInTryAdd(this.Name, ElementCount); } } return(result); }