Export (0) Print
Expand All

XpsDocumentWriter.WritingCompleted Event

Occurs when a write operation finishes.

Namespace:  System.Windows.Xps
Assembly:  System.Printing (in System.Printing.dll)

Public Overrides Event WritingCompleted As WritingCompletedEventHandler

The following example shows how to use the WritingCompleted event.

		Private Sub SaveMultipleFixedContentDocumentsAsync(ByVal xpsdw As XpsDocumentWriter, ByVal fds As FixedDocumentSequence)
			_xpsdwActive = xpsdw

			AddHandler xpsdw.WritingCompleted, AddressOf AsyncSaveCompleted

			AddHandler xpsdw.WritingProgressChanged, AddressOf AsyncSavingProgress

			' Write the FixedDocumentSequence as a
			' collection of documents asynchronously.
		End Sub

		' Cancel an async operation
		Public Sub CancelAsync()
		End Sub
		#End Region ' Asynchronous Save Methods

		#Region "Async Event Handlers"
		' Create an "async operation complete" event handler
		' for saving a FixedDocumentSequence
		Private Sub AsyncSaveCompleted(ByVal sender As Object, ByVal e As WritingCompletedEventArgs)
			Dim result As String
			If e.Cancelled Then
				result = "Canceled"
			ElseIf e.Error IsNot Nothing Then
				result = "Error"
				result = "Asynchronous operation Completed"
			End If

			' Close the pakcage

			If OnAsyncSaveChangeEvent IsNot Nothing Then
				Dim asyncInfo As New AsyncSaveEventArgs(result, True)
				RaiseEvent OnAsyncSaveChange(Me, asyncInfo)
			End If
		End Sub

		' Create an "async operation progress" event handler for
		' monitoring the progress of saving a FixedDocumentSequence.
		Private Sub AsyncSavingProgress(ByVal sender As Object, ByVal e As WritingProgressChangedEventArgs)
			_batchProgress += 1

			If OnAsyncSaveChangeEvent IsNot Nothing Then
				Dim progress As String = String.Format("{0} - {1}", e.WritingLevel.ToString(), e.Number.ToString())
				Dim asyncInfo As New AsyncSaveEventArgs(progress, False)
				RaiseEvent OnAsyncSaveChange(Me, asyncInfo)
			End If

			' Call EndBatchWrite when serializing multiple visuals.
			If (_activeVtoXPSD IsNot Nothing) AndAlso (_batchProgress = 3) Then
			End If
		End Sub

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft