Share via


PipeStream.BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 方法

定义

开始异步写操作。

public:
 override IAsyncResult ^ BeginWrite(cli::array <System::Byte> ^ buffer, int offset, int count, AsyncCallback ^ callback, System::Object ^ state);
public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback? callback, object? state);
public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback callback, object state);
[System.Security.SecurityCritical]
public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback callback, object state);
override this.BeginWrite : byte[] * int * int * AsyncCallback * obj -> IAsyncResult
[<System.Security.SecurityCritical>]
override this.BeginWrite : byte[] * int * int * AsyncCallback * obj -> IAsyncResult
Public Overrides Function BeginWrite (buffer As Byte(), offset As Integer, count As Integer, callback As AsyncCallback, state As Object) As IAsyncResult

参数

buffer
Byte[]

包含要写入当前流的数据的缓冲区。

offset
Int32

buffer 中的从零开始的字节偏移量,从此处开始将字节复制到当前流。

count
Int32

最多写入的字节数。

callback
AsyncCallback

异步写操作完成后调用的方法。

state
Object

一个用户提供的对象,它将该特定的异步写入请求与其他请求区别开来。

返回

一个引用异步写操作的 IAsyncResult 对象。

属性

例外

buffernull

offset 小于 0。

count 小于 0。

count 大于 buffer 中可用的字节数。

管道已关闭。

管道不支持写操作。

管道已断开连接、正在等待连接或尚未设置句柄。

管道已中断或出现其他 I/O 错误。

注解

EndWrite 每次调用 BeginWrite都必须调用一次。 这可以在调用 BeginWrite 的相同代码中完成,也可以在传递给 的 BeginWrite回调中完成。

CanWrite使用 属性确定当前PipeStream对象是否支持写入操作。

如果管道关闭或将无效参数传递给 BeginWrite,则会立即引发相应的异常。 异步写入请求期间发生的错误发生在正在执行请求的线程池线程上。 代码调用 EndWrite 方法时会引发异常。

适用于