As @Noseratio commented, the AsTask
in the linked article is for WinRT asynchronous operations, not BCL types.
In your case, you can just pass the cancellation token directly to the method:
var cancelationToken = new CancellationTokenSource(timeoutMs).Token;
...
var rx = await stream.ReadAsync(buffer, offset, count, cancellationToken);