Click or drag to resize
ReadAsyncCallback Delegate
References a method to be called when bytes need to be read from a source asynchronously.

Namespace: Lawo.IO
Assembly: Lawo (in Lawo.dll) Version: 1.4.1707.27006
Syntax
C#
public delegate Task<int> ReadAsyncCallback(
	byte[] buffer,
	int offset,
	int count,
	CancellationToken cancellationToken
)

Parameters

buffer
Type: SystemByte
offset
Type: SystemInt32
count
Type: SystemInt32
cancellationToken
Type: System.ThreadingCancellationToken

Return Value

Type: TaskInt32
Remarks
The referenced method must behave like ReadAsync(Byte, Int32, Int32, CancellationToken). Notably, calling code that needs to cancel a read operation will do so as follows:
  1. It will call Cancel on the object from which cancellationToken originated and wait for an OperationCanceledException to be thrown.
  2. If no OperationCanceledException is thrown within say 500 milliseconds, Dispose is called on the object representing the source and the caller then waits for either an OperationCanceledException or an ObjectDisposedException.
The steps above ensure that cancellation will work correctly for APIs that do support CancellationToken as well as for those that don't (where the recommended practice is to simply call Dispose on the object representing the source.
See Also