Esempio n. 1
0
        /// <summary>
        /// Creates a <see cref="ProcessDictionary{TKey, TValue}"/> based on the generic <see cref="DictionaryList{TKey, TValue}"/> class.
        /// </summary>
        /// <param name="processItemFunction">A delegate <see cref="ProcessItemFunctionSignature"/> that defines a function signature to process a key and value one at a time.</param>
        /// <param name="canProcessItemFunction">A delegate <see cref="CanProcessItemFunctionSignature"/> that determines if a key and value can currently be processed.</param>
        /// <param name="processInterval">A <see cref="double"/> which represents the process interval.</param>
        /// <param name="maximumThreads">An <see cref="int"/> that represents the max number of threads to use.</param>
        /// <param name="processTimeout">An <see cref="int"/> that represents the amount of time before a process times out.</param>
        /// <param name="requeueOnTimeout">A <see cref="bool"/> value that indicates whether the process should requeue the item after a timeout.</param>
        /// <param name="requeueOnException">A <see cref="bool"/> value that indicates whether the process should requeue the item after an exception.</param>
        public ProcessDictionary(ProcessItemFunctionSignature processItemFunction, CanProcessItemFunctionSignature canProcessItemFunction = null, double processInterval = DefaultProcessInterval, int maximumThreads = DefaultMaximumThreads, int processTimeout = DefaultProcessTimeout, bool requeueOnTimeout = DefaultRequeueOnTimeout, bool requeueOnException = DefaultRequeueOnException)
            : base(null, null, null, new DictionaryList <TKey, TValue>(), processInterval, maximumThreads, processTimeout, requeueOnTimeout, requeueOnException)
        {
            m_processItemFunction    = processItemFunction; // Defining this function creates a ProcessingStyle = OneAtATime keyed process queue
            m_canProcessItemFunction = canProcessItemFunction;

            // Assigns translator functions for base class.
            base.ProcessItemFunction = ProcessKeyedItem;

            if ((object)m_canProcessItemFunction != null)
            {
                base.CanProcessItemFunction = CanProcessKeyedItem;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Releases the unmanaged resources used by the <see cref="ProcessDictionary{TKey, TValue}"/> object and optionally releases the managed resources.
 /// </summary>
 /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
 protected override void Dispose(bool disposing)
 {
     if (!m_disposed)
     {
         try
         {
             if (disposing)
             {
                 m_processItemFunction    = null;
                 m_canProcessItemFunction = null;
             }
         }
         finally
         {
             m_disposed = true;       // Prevent duplicate dispose.
             base.Dispose(disposing); // Call base class Dispose().
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Creates a <see cref="ProcessDictionary{TKey, TValue}"/> based on the generic <see cref="DictionaryList{TKey, TValue}"/> class.
 /// </summary>
 /// <param name="processItemFunction">A delegate <see cref="ProcessItemFunctionSignature"/> that defines a function signature to process a key and value one at a time.</param>
 /// <param name="processInterval">A <see cref="double"/> which represents the process interval.</param>
 /// <param name="maximumThreads">An <see cref="int"/> that represents the max number of threads to use.</param>
 /// <param name="processTimeout">An <see cref="int"/> that represents the amount of time before a process times out.</param>
 /// <param name="requeueOnTimeout">A <see cref="bool"/> value that indicates whether the process should requeue the item after a timeout.</param>
 /// <param name="requeueOnException">A <see cref="bool"/> value that indicates whether the process should requeue the item after an exception.</param>
 public ProcessDictionary(ProcessItemFunctionSignature processItemFunction, double processInterval = DefaultProcessInterval, int maximumThreads = DefaultMaximumThreads, int processTimeout = DefaultProcessTimeout, bool requeueOnTimeout = DefaultRequeueOnTimeout, bool requeueOnException = DefaultRequeueOnException)
     : this(processItemFunction, null, processInterval, maximumThreads, processTimeout, requeueOnTimeout, requeueOnException)
 {
 }