Esempio n. 1
0
            public IOAsyncResult(PersistencePipeline pipeline, bool isLoad, TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                _pipeline         = pipeline;
                _isLoad           = isLoad;
                _pendingModules   = _pipeline._modules.Where(value => value.IsIOParticipant).ToArray();
                _remainingModules = _pendingModules.Length;

                bool completeSelf = false;

                if (_pendingModules.Length == 0)
                {
                    completeSelf = true;
                }
                else
                {
                    for (int i = 0; i < _pendingModules.Length; i++)
                    {
                        Fx.Assert(!completeSelf, "Shouldn't have been completed yet.");

                        IPersistencePipelineModule module = _pendingModules[i];
                        IAsyncResult result = null;
                        try
                        {
                            if (_isLoad)
                            {
                                result = module.BeginOnLoad(_pipeline._readWriteView, timeout, Fx.ThunkCallback(new AsyncCallback(OnIOComplete)), i);
                            }
                            else
                            {
                                result = module.BeginOnSave(_pipeline._readWriteView, _pipeline._writeOnlyView, timeout, Fx.ThunkCallback(new AsyncCallback(OnIOComplete)), i);
                            }
                        }
                        catch (Exception exception)
                        {
                            if (Fx.IsFatal(exception))
                            {
                                throw;
                            }

                            _pendingModules[i] = null;
                            ProcessException(exception);
                        }
                        if (result == null)
                        {
                            if (CompleteOne())
                            {
                                completeSelf = true;
                            }
                        }
                        else if (result.CompletedSynchronously)
                        {
                            _pendingModules[i] = null;
                            if (IOComplete(result, module))
                            {
                                completeSelf = true;
                            }
                        }
                    }
                }

                if (completeSelf)
                {
                    Complete(true, _exception);
                }
            }
            public IOAsyncResult(PersistencePipeline pipeline, bool isLoad, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
            {
                this.pipeline       = pipeline;
                this.isLoad         = isLoad;
                this.pendingModules = (from value in this.pipeline.modules
                                       where value.IsIOParticipant
                                       select value).ToArray <IPersistencePipelineModule>();
                this.remainingModules = this.pendingModules.Length;
                bool flag = false;

                if (this.pendingModules.Length == 0)
                {
                    flag = true;
                }
                else
                {
                    for (int i = 0; i < this.pendingModules.Length; i++)
                    {
                        IPersistencePipelineModule module = this.pendingModules[i];
                        IAsyncResult result = null;
                        try
                        {
                            if (this.isLoad)
                            {
                                result = module.BeginOnLoad(this.pipeline.readWriteView, timeout, Fx.ThunkCallback(new AsyncCallback(this.OnIOComplete)), i);
                            }
                            else
                            {
                                result = module.BeginOnSave(this.pipeline.readWriteView, this.pipeline.writeOnlyView, timeout, Fx.ThunkCallback(new AsyncCallback(this.OnIOComplete)), i);
                            }
                        }
                        catch (Exception exception)
                        {
                            if (Fx.IsFatal(exception))
                            {
                                throw;
                            }
                            this.pendingModules[i] = null;
                            this.ProcessException(exception);
                        }
                        if (result == null)
                        {
                            if (this.CompleteOne())
                            {
                                flag = true;
                            }
                        }
                        else if (result.CompletedSynchronously)
                        {
                            this.pendingModules[i] = null;
                            if (this.IOComplete(result, module))
                            {
                                flag = true;
                            }
                        }
                    }
                }
                if (flag)
                {
                    base.Complete(true, this.exception);
                }
            }