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 方法時,就會引發例外狀況。

適用於