/// <summary> /// Begins an asynchronous read operation. (Consider using AsyncStream.ReadAsync(System.Byte[],System.Int32,System.Int32,System.Threading.CancellationToken) /// instead.) /// </summary> /// <param name="buffer">The buffer to read data into.</param> /// <param name="offset">The byte offset in array at which to begin reading.</param> /// <param name="count">The maximum number of bytes to read.</param> /// <param name="callback">The method to be called when the asynchronous read operation is completed.</param> /// <param name="state">A user-provided object that distinguishes this particular asynchronous read request /// from other requests.</param> /// <returns>An object that references the asynchronous read.</returns> /// <exception cref="System.ArgumentNullException"> /// buffer is null. /// </exception> /// <exception cref="System.ArgumentException"> /// offset and count describe an invalid range in array. /// </exception> /// <exception cref="System.NotSupportedException"> /// FollowingFileStream.CanRead for this stream is false. /// </exception> /// <exception cref="System.InvalidOperationException"> /// The stream is currently in use by a previous read operation. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// offset or count is negative. /// </exception> /// <exception cref="System.IO.IOException"> /// An asynchronous read was attempted past the end of the file. /// </exception> public sealed override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { return(ApmAsyncFactory.ToBegin( this.ReadAsync(buffer, offset, count, CancellationToken.None), callback, state)); }
public override bool EndInvokeAction(IAsyncResult asyncResult) { return(ApmAsyncFactory.ToEnd <bool>(asyncResult)); }
public override IAsyncResult BeginInvokeAction(ControllerContext controllerContext, string actionName, AsyncCallback callback, object state) { var task = InvokeActionAsync(controllerContext, actionName); return(ApmAsyncFactory.ToBegin(task, callback, state)); }
/// <summary> /// Waits for the pending asynchronous write operation to complete. (Consider using /// AsyncStream.WriteAsync(System.Byte[],System.Int32,System.Int32,System.Threading.CancellationToken) /// instead.) /// </summary> /// <param name="asyncResult">The reference to the pending asynchronous request to wait for.</param> /// <exception cref="System.ArgumentNullException"> /// asyncResult is null. /// </exception> /// <exception cref="System.ArgumentException"> /// This System.IAsyncResult object was not created by calling AsyncStream.BeginWrite(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object) /// on this class. /// </exception> /// <exception cref="System.InvalidOperationException"> /// AsyncStream.EndWrite(System.IAsyncResult) is called multiple times. /// </exception> /// <exception cref="System.IO.IOException"> /// The stream is closed or an internal error has occurred. /// </exception> public sealed override void EndWrite(IAsyncResult asyncResult) { ApmAsyncFactory.ToEnd(asyncResult); }
/// <summary> /// Waits for the pending asynchronous read operation to complete. (Consider using /// AsyncStream.ReadAsync(System.Byte[],System.Int32,System.Int32,System.Threading.CancellationToken) /// instead.) /// </summary> /// <param name="asyncResult">The reference to the pending asynchronous request to wait for.</param> /// <returns> /// The number of bytes read from the stream, between 0 and the number of bytes you /// requested. Streams only return 0 at the end of the stream, otherwise, they should /// block until at least 1 byte is available. /// </returns> /// <exception cref="System.ArgumentNullException"> /// asyncResult is null. /// </exception> /// <exception cref="System.ArgumentException"> /// This System.IAsyncResult object was not created by calling AsyncStream.BeginRead(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object) /// on this class. /// </exception> /// <exception cref="System.InvalidOperationException"> /// AsyncStream.EndRead(System.IAsyncResult) is called multiple times. /// </exception> /// <exception cref="System.IO.IOException"> /// The stream is closed or an internal error has occurred. /// </exception> public sealed override int EndRead(IAsyncResult asyncResult) { return(ApmAsyncFactory.ToEnd <int>(asyncResult)); }