←Select platform

LoadDocumentAsyncOptions Class

Summary

Options to use when loading a document asynchronously.

Syntax
C#
C++/CLI
Python
public class LoadDocumentAsyncOptions : LoadDocumentOptions 
public ref class LoadDocumentAsyncOptions : LoadDocumentOptions 
class LoadDocumentAsyncOptions(LoadDocumentOptions): 
Remarks

Used with DocumentFactory.LoadFromUriAsync to specify extra options to use when loading documents asynchronously.

LoadDocumentAsyncOptions derives from LoadDocumentOptions and should be setup in the same way. Loading a document asynchronously will return control to the user right away and the document is loaded in a separate thread. Therefore, LoadDocumentAsyncOptions adds the following members to easily track the status of the load operation:

  • Progress: Event that indicate the current load progress.

  • Completed: Event that indicate when the load operation is completed.

  • UserState: User-define data that can be associated with the load operation.

Refer to Loading Documents using Leadtools.Document for detailed information.

Example
C#
using Leadtools; 
using Leadtools.Caching; 
using Leadtools.Document; 
 
 
public void DocumentFactoryLoadFromUriAsyncExample() 
{ 
   AutoResetEvent finished = null; 
   EventHandler<LoadAsyncCompletedEventArgs> completed = null; 
   // LoadAsyncProgressEventArgs reference 
   EventHandler<LoadAsyncProgressEventArgs> progress = null; 
 
   completed = (sender, e) => 
   { 
      //Assert((int)e.UserState == 1); 
 
      if (e.Cancelled) 
         Console.WriteLine("Canceled"); 
      if (e.Error != null) 
         Console.WriteLine("Error:" + e.Error.Message); 
      if (e.Document == null) 
         Console.WriteLine("Document is null"); 
 
      var thisOptions = sender as LoadDocumentAsyncOptions; 
      thisOptions.Completed -= completed; 
 
      if (e.Document != null) 
      { 
         PrintOutDocumentInfo(e.Document); 
      } 
 
      finished.Set(); 
      Console.WriteLine("Done"); 
   }; 
 
   progress = (sender, f) => 
   { 
      Console.WriteLine(f.BytesReceived); 
      Console.WriteLine(f.IsCancelPending); 
      Console.WriteLine(f.TotalBytesToReceive); 
 
      var thisOptions = sender as LoadDocumentAsyncOptions; 
      thisOptions.Progress -= progress; 
   }; 
 
   var options = new LoadDocumentAsyncOptions(); 
   options.Completed += completed; 
 
   finished = new AutoResetEvent(false); 
   DocumentFactory.LoadFromUriAsync(new Uri("http://localhost/Leadtools.pdf"), options); 
   finished.WaitOne(); 
} 
Requirements

Target Platforms

Help Version 22.0.2023.4.21
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.