IsolatedStorageFileStream.BeginWrite 方法

定義

開始非同步寫入。

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

參數

bufferarray
Byte[]

寫入資料的緩衝區。

offset
Int32

buffer 中的位元組位移,即開始寫入的位置。

numBytes
Int32

寫入的最大位元組數。

userCallback
AsyncCallback

在完成非同步寫入作業時呼叫的方法。 這是選擇性參數。

stateObject
Object

非同步寫入的狀態。

傳回

IAsyncResult,表示可能還在暫止中的非同步寫入。 這個 IAsyncResult 必須傳遞給資料流的 EndWrite(IAsyncResult) 方法,以確保寫入完成,然後適當地釋放資源。 若要做到這點,可以使用與呼叫 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 相同的程式碼,或者在傳遞至 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 的回呼中做到。

例外狀況

在超過檔案結尾處嘗試了非同步寫入。

備註

IsolatedStorageFileStream如果對像是可寫入的,則數據流結尾的寫入會展開數據流。

當您發出異步讀取或寫入時,數據流中的目前位置會更新,而不是在 I/O 作業完成時更新。

您必須使用IAsyncResult這個方法傳回的物件呼叫 EndWrite ,以找出已寫入的位元組數目。

適用於