PrefetchAsync(CancellationToken) Method

Definition

Namespace Broadside
Assembly Broadside.dll

Fetches, asynchronously, the objects reading this page needs, so that interpreting it afterwards never waits on the network: the page object, its resources (inherited ones included), its content streams, annotations and their appearances, and everything they refer to, but not other pages.

public Task PrefetchAsync(CancellationToken cancellationToken = default(CancellationToken))

Parameters

cancellationToken
CancellationToken

Cancels the requests.

Returns

Task
A task that completes when the objects are cached; already completed for a document whose bytes are all at hand.

Remarks

Spec #33, viewer capability 5. Only a document opened through OpenAsync(HttpClient, Uri, CancellationToken) fetches anything. Where SynchronousRangeFetch is off (always on the browser, which cannot block on HTTP), a synchronous read of a page before its prefetch throws PdfRangeNotLoadedException; elsewhere it blocks on the requests instead, and a prefetch only makes them parallel and asynchronous. The bytes stay cached up to RangeCacheLimit.