static void AsyncCompletionWrapperCallback(IAsyncResult result) { if (result == null) { throw Fx.Exception.AsError(new InvalidOperationException(SRCore.InvalidNullAsyncResult)); } if (result.CompletedSynchronously) { return; } AsyncResult thisPtr = (AsyncResult)result.AsyncState; if (thisPtr.transactionContext != null && !thisPtr.transactionContext.Signal(result)) { // The TransactionScope isn't cleaned up yet and can't be done on this thread. Must defer // the callback (which is likely to attempt to commit the transaction) until later. return; } AsyncCompletion callback = thisPtr.GetNextCompletion(); if (callback == null) { ThrowInvalidAsyncResult(result); } bool completeSelf = false; Exception completionException = null; try { completeSelf = callback(result); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } completeSelf = true; completionException = e; } if (completeSelf) { thisPtr.Complete(false, completionException); } }
private static void AsyncCompletionWrapperCallback(IAsyncResult result) { if (result == null) { throw Fx.Exception.AsError(new InvalidOperationException(SRCore.InvalidNullAsyncResult), null); } if (result.CompletedSynchronously) { return; } AsyncResult asyncState = (AsyncResult)result.AsyncState; if (asyncState.transactionContext != null && !asyncState.transactionContext.Signal(result)) { return; } AsyncResult.AsyncCompletion nextCompletion = asyncState.GetNextCompletion(); if (nextCompletion == null) { AsyncResult.ThrowInvalidAsyncResult(result); } bool flag = false; Exception exception = null; try { flag = nextCompletion(result); } catch (Exception exception2) { Exception exception1 = exception2; if (Fx.IsFatal(exception1)) { throw; } flag = true; exception = exception1; } if (flag) { asyncState.Complete(false, exception); } }