Exemplo n.º 1
0
 public FatalException(string message, Exception innerException) : base(message, innerException)
 {
     // This can't throw something like ArgumentException because that would be worse than
     // throwing the fatal exception that was requested.
     Fx.Assert(innerException == null || !Fx.IsFatal(innerException), "FatalException can't be used to wrap fatal exceptions.");
 }
Exemplo n.º 2
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);
                }
            }