Ejemplo n.º 1
0
 protected AsyncCallback PrepareAsyncCompletion(AsyncResult.AsyncCompletion callback)
 {
     if (this.beforePrepareAsyncCompletionAction != null)
     {
         this.beforePrepareAsyncCompletionAction();
     }
     this.nextAsyncCompletion = callback;
     if (AsyncResult.asyncCompletionWrapperCallback == null)
     {
         AsyncResult.asyncCompletionWrapperCallback = Fx.ThunkCallback(new AsyncCallback(AsyncResult.AsyncCompletionWrapperCallback));
     }
     return(AsyncResult.asyncCompletionWrapperCallback);
 }
Ejemplo n.º 2
0
 public ScheduledOverlapped()
 {
     if (s_isWindows)
     {
         _nativeOverlapped = (new Overlapped()).UnsafePack(
             Fx.ThunkCallback(new IOCompletionCallback(IOCallback)), null);
         _postDelegate = PostIOCP;
     }
     else
     {
         _postDelegate = PostNewThread;
     }
 }
Ejemplo n.º 3
0
 protected AsyncCallback PrepareAsyncCompletion(AsyncCompletion callback)
 {
     if (this.transactionContext != null)
     {
         if (this.transactionContext.IsPotentiallyAbandoned)
         {
             this.transactionContext = null;
         }
         else
         {
             this.transactionContext.Prepared();
         }
     }
     this.nextAsyncCompletion = callback;
     if (asyncCompletionWrapperCallback == null)
     {
         asyncCompletionWrapperCallback = Fx.ThunkCallback(new AsyncCallback(AsyncResult.AsyncCompletionWrapperCallback));
     }
     return(asyncCompletionWrapperCallback);
 }
Ejemplo n.º 4
0
 public unsafe ScheduledOverlapped()
 {
     this.nativeOverlapped = new Overlapped().UnsafePack(Fx.ThunkCallback(new IOCompletionCallback(this.IOCallback)), null);
 }
 static IOThreadCancellationTokenSource()
 {
     IOThreadCancellationTokenSource.onCancel = Fx.ThunkCallback <object>(new Action <object>(IOThreadCancellationTokenSource.OnCancel));
 }
Ejemplo n.º 6
0
            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);
                }
            }