/// <summary>
        /// Stop the specified operation.
        /// </summary>
        /// <param name="operation">Operation which needs to be stopped.</param>
        internal void StopOperation(IThrottleOperation operation)
        {
            // StopOperation is being called a second time
            // or the stop operation has already completed
            // - in either case just return
            if (operation.IgnoreStop)
            {
                return;
            }

            // If the operation has not yet been started, then
            // remove it from the pending queue
            if (_operationsQueue.IndexOf(operation) != -1)
            {
                lock (_syncObject)
                {
                    if (_operationsQueue.IndexOf(operation) != -1)
                    {
                        _operationsQueue.Remove(operation);
                        RaiseThrottleManagerEvents();
                        return;
                    }
                }
            }

            // The operation has already started, then add it
            // to the inprocess queue and call stop. Refer to
            // comment in StopAllOperations() as to why this is
            // being added a second time
            lock (_syncObject)
            {
                _stopOperationQueue.Add(operation);

                operation.IgnoreStop = true;
            }

            // stop the operation outside of the lock
            operation.StopOperation();
        }
Example #2
0
 internal void StopOperation(IThrottleOperation operation)
 {
     if (!operation.IgnoreStop)
     {
         if (this.operationsQueue.IndexOf(operation) != -1)
         {
             lock (this.syncObject)
             {
                 if (this.operationsQueue.IndexOf(operation) != -1)
                 {
                     this.operationsQueue.Remove(operation);
                     this.RaiseThrottleManagerEvents();
                     return;
                 }
             }
         }
         lock (this.syncObject)
         {
             this.stopOperationQueue.Add(operation);
             operation.IgnoreStop = true;
         }
         operation.StopOperation();
     }
 }
Example #3
0
 internal void StopOperation(IThrottleOperation operation)
 {
     if (!operation.IgnoreStop)
     {
         if (this.operationsQueue.IndexOf(operation) != -1)
         {
             lock (this.syncObject)
             {
                 if (this.operationsQueue.IndexOf(operation) != -1)
                 {
                     this.operationsQueue.Remove(operation);
                     this.RaiseThrottleManagerEvents();
                     return;
                 }
             }
         }
         lock (this.syncObject)
         {
             this.stopOperationQueue.Add(operation);
             operation.IgnoreStop = true;
         }
         operation.StopOperation();
     }
 }
Example #4
0
        } // StopAllOperations

        /// <summary>
        /// Stop the specified operation
        /// </summary>
        /// <param name="operation">operation which needs to be stopped</param>
        internal void StopOperation(IThrottleOperation operation)
        {
            // StopOperation is being called a second time
            // or the stop operation has already completed
            // - in either case just return
            if (operation.IgnoreStop)
            {
                return;
            }

            // If the operation has not yet been started, then
            // remove it from the pending queue 
            if (_operationsQueue.IndexOf(operation) != -1)
            {
                lock (_syncObject)
                {
                    if (_operationsQueue.IndexOf(operation) != -1)
                    {
                        _operationsQueue.Remove(operation);
                        RaiseThrottleManagerEvents();
                        return;
                    }
                }
            }

            // The operation has already started, then add it
            // to the inprocess queue and call stop. Refer to
            // comment in StopAllOperations() as to why this is
            // being added a second time
            lock (_syncObject)
            {
                _stopOperationQueue.Add(operation);

                operation.IgnoreStop = true;
            }

            // stop the operation outside of the lock
            operation.StopOperation();
        }