ComponentOne PDF for WPF and Silverlight
Aynchronous Loading
PDF for WPF and Silverlight Overview > Features: PDF for WPF and Silverlight > Loading Documents > Aynchronous Loading

For better performance you can have the C1PdfViewer control load documents in the background asynchronously. Using the .NET await keyword, you can easily call asynchronous methods. To open a file selected by the user asynchronously, complete the following code:

Visual Basic
Copy Code
Dim openPicker As New FileOpenPicker()

openPicker.FileTypeFilter.Add(".pdf")

Dim file As StorageFile = Await openPicker.PickSingleFileAsync()

If file IsNot Nothing Then
      
       Dim stream As Stream = Await file.OpenStreamForReadAsync()
      
       Await pdfViewer.LoadDocumentAsync(stream)
End If
C#
Copy Code
FileOpenPicker openPicker = new FileOpenPicker();

openPicker.FileTypeFilter.Add(".pdf");

StorageFile file = await openPicker.PickSingleFileAsync();

if (file != null)

{

    Stream stream = await file.OpenStreamForReadAsync();

    await pdfViewer.LoadDocumentAsync(stream);

}