public void SetAsyncResult(CompletingAsyncResult result) { if (_result != null) { throw new InvalidOperationException("SetAsyncResult has already been called."); } _result = result; }
public static IReturnsResult <Stream> ReturnsCompletingAsynchronously(this ISetup <Stream, IAsyncResult> setup, AsyncCompletionSource completionSource) { if (setup == null) { throw new ArgumentNullException(nameof(setup)); } return(setup.Returns <byte[], int, int, AsyncCallback, object>((i1, i2, i3, callback, state) => { CompletingAsyncResult result = new CompletingAsyncResult(callback, state); completionSource.SetAsyncResult(result); return result; })); }