System.Collections.Concurrent.BlockingCollection.CheckDisposed()

Here are the examples of the csharp api class System.Collections.Concurrent.BlockingCollection.CheckDisposed() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

1. Example

Project: referencesource
Source File: BlockingCollection.cs
public T[] ToArray()
        {
            CheckDisposed();
            return m_collection.ToArray();
        }

2. Example

Project: referencesource
Source File: BlockingCollection.cs
void ICollection.CopyTo(Array array, int index)
        {
            CheckDisposed();

            //We don't call m_collection.CopyTo() directly because we rely on Array.Copy method to customize 
            //all array exceptions.  
            T[] collectionSnapShot = m_collection.ToArray();

            try
            {
                Array.Copy(collectionSnapShot, 0, array, index, collectionSnapShot.Length);
            }
            catch (ArgumentNullException)
            {
                throw new ArgumentNullException("array");
            }
            catch (ArgumentOutOfRangeException)
            {
                throw new ArgumentOutOfRangeException("index", index, SR.GetString(SR.BlockingCollection_CopyTo_NonNegative));
            }
            catch (ArgumentException)
            {
                throw new ArgumentException(SR.GetString(SR.BlockingCollection_CopyTo_TooManyElems), "index");
            }
            catch (RankException)
            {
                throw new ArgumentException(SR.GetString(SR.BlockingCollection_CopyTo_MultiDim), "array");
            }
            catch (InvalidCastException)
            {
                throw new ArgumentException(SR.GetString(SR.BlockingCollection_CopyTo_IncorrectType), "array");
            }
            catch (ArrayTypeMismatchException)
            {
                throw new ArgumentException(SR.GetString(SR.BlockingCollection_CopyTo_IncorrectType), "array");
            }
        }

3. Example

Project: referencesource
Source File: BlockingCollection.cs
IEnumerator<T> IEnumerable<T>.GetEnumerator()
        {
            CheckDisposed();
            return m_collection.GetEnumerator();

        }

4. Example

Project: referencesource
Source File: BlockingCollection.cs
private bool TryTakeWithNoTimeValidation(out T item, int millisecondsTimeout, CancellationToken canc/n ..... /n //View Source file for more details /n }

5. Example

Project: referencesource
Source File: BlockingCollection.cs
public void CompleteAdding()
        {
            CheckDisposed();

            if (IsAddingCompleted)
                return;

            SpinWait spinner = new SpinWait();
            while (true)
            {
                int observedAdders = m_currentAdders;
                if ((observedAdders & COMPLETE_ADDING_ON_MASK) != 0)
                {
                    spinner.Reset();
                    // If there is another COmpleteAdding in progress waiting the current adders, then spin until it finishes
                    while (m_currentAdders != COMPLETE_ADDING_ON_MASK) spinner.SpinOnce();
                    return;
                }

                if (Interlocked.CompareExchange(ref m_currentAdders, observedAdders | COMPLETE_ADDING_ON_MASK, observedAdders) == observedAdders)
                {
                    spinner.Reset();
                    while (m_currentAdders != COMPLETE_ADDING_ON_MASK) spinner.SpinOnce();

                    if (Count == 0)
                    {
                        CancelWaitingConsumers();
                    }

                    // We should always wake waiting producers, and have them throw exceptions as
                    // Add&CompleteAdding should not be used concurrently.
                    CancelWaitingProducers();
                    return;

                }
                spinner.SpinOnce();
            }
        }

6. Example

Project: referencesource
Source File: BlockingCollection.cs
private bool TryAddWithNoTimeValidation(T item, int millisecondsTimeout, CancellationToken cancellat/n ..... /n //View Source file for more details /n }