/// <summary> /// Creates an implementation of the IAsyncResult with the specified behavior /// </summary> /// <param name="behavior">The behavior to use for the IAsyncResult.</param> /// <param name="callback">The callback for the async operation</param> /// <param name="state">The state of the callback.</param> /// <returns>The newly create IAsyncResult implementation.</returns> public static TestAsyncResult Create(AsyncMethodBehavior behavior, AsyncCallback callback, object state) { switch (behavior) { case AsyncMethodBehavior.Synchronous: return new SynchronousTestAsyncResult(callback, state); case AsyncMethodBehavior.AsynchronousImmediateSameThread: return new AsynchronousImmediateSameThreadTestAsyncResult(callback, state); case AsyncMethodBehavior.AsynchronousImmediateDifferentThread: return new AsynchronousImmediateDifferentThreadTestAsyncResult(callback, state); case AsyncMethodBehavior.AsynchronousDelayed: return new AsynchronousDelayedTestAsyncResult(callback, state); default: throw new ArgumentException("Unrecognized behavior.", "behavior"); } }
/// <summary> /// Creates an implementation of the IAsyncResult with the specified behavior /// </summary> /// <param name="behavior">The behavior to use for the IAsyncResult.</param> /// <param name="callback">The callback for the async operation</param> /// <param name="state">The state of the callback.</param> /// <returns>The newly create IAsyncResult implementation.</returns> public static TestAsyncResult Create(AsyncMethodBehavior behavior, AsyncCallback callback, object state) { switch (behavior) { case AsyncMethodBehavior.Synchronous: return(new SynchronousTestAsyncResult(callback, state)); case AsyncMethodBehavior.AsynchronousImmediateSameThread: return(new AsynchronousImmediateSameThreadTestAsyncResult(callback, state)); case AsyncMethodBehavior.AsynchronousImmediateDifferentThread: return(new AsynchronousImmediateDifferentThreadTestAsyncResult(callback, state)); case AsyncMethodBehavior.AsynchronousDelayed: return(new AsynchronousDelayedTestAsyncResult(callback, state)); default: throw new ArgumentException("Unrecognized behavior.", "behavior"); } }