Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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.");
            }
        }