public IOAsyncResult(PersistencePipeline pipeline, bool isLoad, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.pipeline = pipeline; this.isLoad = isLoad; this.pendingModules = this.pipeline.modules.Where(value => value.IsIOParticipant).ToArray(); this.remainingModules = this.pendingModules.Length; bool completeSelf = false; if (this.pendingModules.Length == 0) { completeSelf = true; } else { for (int i = 0; i < this.pendingModules.Length; i++) { Fx.Assert(!completeSelf, "Shouldn't have been completed yet."); IPersistencePipelineModule module = this.pendingModules[i]; IAsyncResult result = null; try { if (this.isLoad) { result = module.BeginOnLoad(this.pipeline.readWriteView, timeout, Fx.ThunkCallback(new AsyncCallback(OnIOComplete)), i); } else { result = module.BeginOnSave(this.pipeline.readWriteView, this.pipeline.writeOnlyView, timeout, Fx.ThunkCallback(new AsyncCallback(OnIOComplete)), i); } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } this.pendingModules[i] = null; ProcessException(exception); } if (result == null) { if (CompleteOne()) { completeSelf = true; } } else if (result.CompletedSynchronously) { this.pendingModules[i] = null; if (IOComplete(result, module)) { completeSelf = true; } } } } if (completeSelf) { Complete(true, this.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); } }