public static IAsyncResult Begin(AsyncCallback callback, object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate <TResult> endDelegate, object tag, int timeout) { WrappedAsyncResult <TResult> asyncResult = new WrappedAsyncResult <TResult>(beginDelegate, endDelegate, tag); asyncResult.Begin(callback, state, timeout); return(asyncResult); }
public static WrappedAsyncResult <TResult> Cast(IAsyncResult asyncResult, object tag) { Assertions.NotNull(asyncResult, "asyncResult"); WrappedAsyncResult <TResult> castResult = asyncResult as WrappedAsyncResult <TResult>; if (castResult != null && Object.Equals(castResult._tag, tag)) { return(castResult); } else { throw new ArgumentException("The provided IAsyncResult is not valid for this method."); } }