/// <summary>
            ///
            /// </summary>
            public void Run()
            {
                bool clearContext = false;

                try
                {
                    if (RepeatSynchronizationManager.GetContext() == null)
                    {
                        clearContext = true;
                        RepeatSynchronizationManager.Register(Context);
                    }
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.Debug("Repeat operation about to start at count= {0}", Context.GetStartedCount());
                    }
                    Result = _callback(Context); //"DoInIteration"
                }
                catch (System.Exception e)
                {
                    Error = e;
                }
                finally
                {
                    if (clearContext)
                    {
                        RepeatSynchronizationManager.Clear();
                    }
                    _queue.Put(this);
                }
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute the batch callback until the completion policy decides that we
        /// are finished. Wait for the whole batch to finish before returning even if
        /// the task executor is asynchronous.
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        public RepeatStatus Iterate(RepeatCallback callback)
        {
            IRepeatContext outer = RepeatSynchronizationManager.GetContext();
            RepeatStatus   result;

            try
            {
                // This works with an asynchronous TaskExecutor: the
                // interceptors have to wait for the child processes.
                result = ExecuteInternal(callback);
            }
            finally
            {
                RepeatSynchronizationManager.Clear();
                if (outer != null)
                {
                    RepeatSynchronizationManager.Register(outer);
                }
            }
            return(result);
        }