Ejemplo n.º 1
0
        public void SetAsyncResult(CompletingAsyncResult result)
        {
            if (_result != null)
            {
                throw new InvalidOperationException("SetAsyncResult has already been called.");
            }

            _result = result;
        }
Ejemplo n.º 2
0
        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;
            }));
        }