←Select platform

Completed Event

Summary

Event that occurs when the factory finishes loading the document successfully or otherwise.

Syntax
C#
C++/CLI
Python
public event EventHandler<LoadAsyncCompletedEventArgs> Completed 
public:  
   event EventHandler<Leadtools::Documents::LoadAsyncCompletedEventArgs^>^ Completed 
def Completed(sender,e): # sender: LoadDocumentAsyncOptions e: LoadAsyncCompletedEventArgs 
Remarks

Completed will occur once when the factory finishes loading the document successfully or otherwise. It uses the LoadAsyncCompletedEventArgs event data class that is populated with the following:

Member Value

System.ComponentModel.AsyncCompletedEventArgs.Cancelled

true if the user has aborted the current operation, false otherwise..

System.ComponentModel.AsyncCompletedEventArgs.UserState

The same value originally set by the user in LoadDocumentAsyncOptions.UserState.

System.ComponentModel.AsyncCompletedEventArgs.Error

The error object thrown if any.

Uri

The location of the document loaded. This is the uri value passed to LoadFromUriAsync

Document

The result LEADDocument object if the load operation was successful, null otherwise

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(); 
} 
Event Data
ParameterTypeDescription
senderobjectThe source of the event.
eLoadAsyncCompletedEventArgsThe event data.
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.