Пример #1
0
 protected AsyncStep CallParallelAsync <TWorkItem>(ICollection <TWorkItem> workItems, BeginCall <TWorkItem> beginCall, EndCall <TWorkItem> endCall, TimeSpan timeout, ExceptionPolicy policy)
 {
     return(this.CallAsync(
                (thisPtr, t, c, s) => new ParallelAsyncResult <TWorkItem>(thisPtr, workItems, beginCall, endCall, timeout, c, s),
                (thisPtr, r) => ParallelAsyncResult <TWorkItem> .End(r),
                policy));
 }
Пример #2
0
            static void OnCompleted(IAsyncResult ar)
            {
                CallbackState state = (CallbackState)ar.AsyncState;
                ParallelAsyncResult <TWorkItem> thisPtr = state.AsyncResult;

                try
                {
                    thisPtr.endCall(thisPtr.iteratorAsyncResult, state.AsyncData, ar);
                    thisPtr.TryComplete(null, false);
                }
                catch (Exception e)
                {
                    thisPtr.TryComplete(e, false);
                }
            }
Пример #3
0
            static void OnCompleted(IAsyncResult ar)
            {
                CallbackState state = (CallbackState)ar.AsyncState;
                ParallelAsyncResult <TWorkItem> thisPtr = state.AsyncResult;

                try
                {
                    thisPtr.endCall(thisPtr.iteratorAsyncResult, state.AsyncData, ar);
                    thisPtr.TryComplete(null, ar.CompletedSynchronously);
                }
                catch (Exception e) when(!Fx.IsFatal(e))
                {
                    thisPtr.TryComplete(e, ar.CompletedSynchronously);
                }
            }
Пример #4
0
 public CallbackState(ParallelAsyncResult <TWorkItem> asyncResult, TWorkItem data)
 {
     this.AsyncResult = asyncResult;
     this.AsyncData   = data;
 }