Redigeeri

Jagamisviis:


DynamicDocumentPaginator.GetPageNumberAsync Method

Definition

Returns the zero-based page number of the specified ContentPosition.

Overloads

GetPageNumberAsync(ContentPosition)

Asynchronously, returns (through the This method raises the GetPageNumberCompleted event) the zero-based page number of the specified ContentPosition.

GetPageNumberAsync(ContentPosition, Object)

Asynchronously, returns (through the This method raises the GetPageNumberCompleted event) the zero-based page number of the specified ContentPosition.

GetPageNumberAsync(ContentPosition)

Asynchronously, returns (through the This method raises the GetPageNumberCompleted event) the zero-based page number of the specified ContentPosition.

public:
 virtual void GetPageNumberAsync(System::Windows::Documents::ContentPosition ^ contentPosition);
public virtual void GetPageNumberAsync (System.Windows.Documents.ContentPosition contentPosition);
abstract member GetPageNumberAsync : System.Windows.Documents.ContentPosition -> unit
override this.GetPageNumberAsync : System.Windows.Documents.ContentPosition -> unit
Public Overridable Sub GetPageNumberAsync (contentPosition As ContentPosition)

Parameters

contentPosition
ContentPosition

The content position whose page number is needed.

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: GetPageNumberAsync(ContentPosition, Object).

This method raises the GetPageNumberCompleted event. The page number is passed to the event as one of the event arguments. See GetPageNumberAsync(ContentPosition, Object) for how to use this method to get the page number.

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 GetPageNumber(ContentPosition).

Applies to

GetPageNumberAsync(ContentPosition, Object)

Asynchronously, returns (through the This method raises the GetPageNumberCompleted event) the zero-based page number of the specified ContentPosition.

public:
 virtual void GetPageNumberAsync(System::Windows::Documents::ContentPosition ^ contentPosition, System::Object ^ userState);
public virtual void GetPageNumberAsync (System.Windows.Documents.ContentPosition contentPosition, object userState);
abstract member GetPageNumberAsync : System.Windows.Documents.ContentPosition * obj -> unit
override this.GetPageNumberAsync : System.Windows.Documents.ContentPosition * obj -> unit
Public Overridable Sub GetPageNumberAsync (contentPosition As ContentPosition, userState As Object)

Parameters

contentPosition
ContentPosition

The content position element to return the page number of.

userState
Object

A unique identifier for the asynchronous task.

Remarks

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

This method raises the GetPageNumberCompleted event.

The following steps illustrate how to retrieve the page number of a given contentPosition asynchronously.

  1. Create a GetPageNumberCompletedEventHandler delegate and add it to be notified of GetPageNumberCompleted events.

  2. Call GetPageNumberAsync(ContentPosition, Object) specifying the contentPosition desired and a unique userState object that will be used to identify the asynchronous task.

  3. When the event occurs and the delegate is called, compare the event's GetPageNumberCompletedEventArgs.UserState property with the original GetPageNumberAsync userState parameter.

  4. When the GetPageNumberCompletedEventArgs.UserState property matches the original GetPageNumberAsync(ContentPosition, Object) userState, the operation is complete and the page number is ready. (The GetPageNumberCompletedEventArgs.ContentPosition property will also match the original GetPageNumberAsync(ContentPosition, Object) contentPosition parameter.)

  5. The GetPageNumberCompletedEventArgs.PageNumber property contains the zero-based page number of the specified contentPosition.

GetPageNumber provides similar functionality as GetPageNumberAsync, but for synchronous operation.

Applies to