Edit

Share via


DocumentPaginator.GetPageAsync Method

Definition

Asynchronously returns the DocumentPage for the specified page number.

Overloads

GetPageAsync(Int32, Object)

Asynchronously returns (through the GetPageCompleted event) the DocumentPage for the specified page number and assigns the specified ID to the asynchronous task.

GetPageAsync(Int32)

Asynchronously returns (through the GetPageCompleted event) the DocumentPage for the specified page number.

GetPageAsync(Int32, Object)

Asynchronously returns (through the GetPageCompleted event) the DocumentPage for the specified page number and assigns the specified ID to the asynchronous task.

public:
 virtual void GetPageAsync(int pageNumber, System::Object ^ userState);
public virtual void GetPageAsync (int pageNumber, object userState);
abstract member GetPageAsync : int * obj -> unit
override this.GetPageAsync : int * obj -> unit
Public Overridable Sub GetPageAsync (pageNumber As Integer, userState As Object)

Parameters

pageNumber
Int32

The zero-based page number of the DocumentPage to get.

userState
Object

A unique identifier for the asynchronous task.

Exceptions

pageNumber is negative.

Remarks

This overload of the method makes it possible to cancel this asynchronous operation without cancelling all asynchronous operations.

This method raises the GetPageCompleted event. The DocumentPage is passed to the event as one of the event arguments.

The following steps illustrate how to retrieve a DocumentPage asynchronously:

  1. Create a GetPageCompletedEventHandler delegate and add it to be notified of GetPageCompleted events.

  2. Call GetPageAsync(Int32, Object) specifying the pageNumber desired and a unique userState, which will be used to identify the completion of the asynchronous event.

  3. When the event occurs and the delegate is called, compare the event's GetPageCompletedEventArgs.UserState property with the original GetPageAsync(Int32, Object) userState parameter. (The GetPageCompletedEventArgs.PageNumber property will also match the pageNumber specified in the GetPageAsync(Int32, Object) call.)

  4. When the GetPageCompletedEventArgs.UserState property matches the original GetPageAsync(Int32, Object) userState, the operation is complete and the page is ready.

  5. Call GetPage to retrieve the formatted DocumentPage.

Applies to

GetPageAsync(Int32)

Asynchronously returns (through the GetPageCompleted event) the DocumentPage for the specified page number.

public:
 virtual void GetPageAsync(int pageNumber);
public virtual void GetPageAsync (int pageNumber);
abstract member GetPageAsync : int -> unit
override this.GetPageAsync : int -> unit
Public Overridable Sub GetPageAsync (pageNumber As Integer)

Parameters

pageNumber
Int32

The zero-based page number of the document page that is needed.

Exceptions

pageNumber is negative.

Remarks

The only way to cancel the asynchronous operation of this method is to cancel all asynchronous operations. Contrast this with the other overload of this method: GetPageAsync(Int32, Object).

This method raises the GetPageCompleted event. The DocumentPage is passed to the event as one of the event arguments. See GetPageAsync(Int32, Object) for how to use this method to get the page.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by GetPage(Int32).

Applies to