Language

MifareClassic.WriteBlockAsync(Int32, Byte[]) Method

Definition

Writes a 16-byte block to the tag on a thread-pool thread.

public System.Threading.Tasks.Task WriteBlockAsync(int blockIndex, byte[]? data);
member this.WriteBlockAsync : int * byte[] -> System.Threading.Tasks.Task

Parameters

blockIndex
Int32

The zero-based index of the block to write, from 0 through 255. The block must be available on the tag.

data
Byte[]

Exactly 16 bytes to write.

Returns

A task that represents the block write operation.

Remarks

This managed wrapper uses Task.Run to call WriteBlock(Int32, Byte[]). Connect and authenticate the block's sector first. The sector's access conditions must permit the write. Await the task before starting another operation.

The synchronous method's connection, access, and NFC permission requirements apply. The method has no cancellation-token parameter. Calling Close() from another thread cancels blocked I/O with IOException. Exceptions from the synchronous call are reported through the task.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to