示例#1
0
        /// <summary></summary>
        protected ThreadSafeEnumerable(IEnumerable<T> component)
        {
            #region Require
            if (component == null) throw new ArgumentNullException();
            #endregion

            // ReaderWriterLock
            _readerWriterLock = new ThreadSafeReaderWriterLock();
            // Component
            _component = component;
        }
示例#2
0
        // Constructor
        /// <summary></summary>
        /// <param name="getEnumeratorDelegate"></param>
        /// <param name="readerWriterLock"></param>
        public ThreadSafeEnumerator(Func<IEnumerator<T>> getEnumeratorDelegate, ThreadSafeReaderWriterLock readerWriterLock)
        {
            #region Require
            if (getEnumeratorDelegate == null) throw new ArgumentNullException();
            if (readerWriterLock == null) throw new ArgumentNullException();
            #endregion

            // ReaderWriterLock
            _readerWriterLock = readerWriterLock;
            _readerWriterLock.EnterReadLock();

            // Component
            _component = getEnumeratorDelegate();
        }