←Select platform

Progress Event

Summary

Event that occurs one or more times while the factory is loading the document to indicate the current progress.

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

Progress will occur one or more times while the document is being loaded and it can be used to show a progress bar indicator for the user (and optionally, support for aborting the load). Progress uses the LoadAsyncProgressEventArgs event data class that is populated with the following for each "chunk":

Member Value

System.ComponentModel.ProgressChangedEventArgs.ProgressPercentage

Current progress percentage. This value goes from 0 to 100..

System.ComponentModel.ProgressChangedEventArgs.UserState

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

Uri

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

BytesReceived

Number of bytes received during this chunk of the operation.

TotalBytesToReceive

Total number of bytes received so far for the whole load operation.

IsCancelPending

Can be used to abort the load operation.

Example
C#
Java
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(); 
} 
 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 
import java.io.IOException; 
import java.io.InputStream; 
import java.net.URI; 
import java.net.URISyntaxException; 
import java.util.Calendar; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.caching.*; 
import leadtools.document.*; 
 
 
// LOAD FROM URI ASYNC DOES NOT EXIST 
Event Data
ParameterTypeDescription
senderobjectThe source of the event.
eLoadAsyncProgressEventArgsThe event data.
Requirements

Target Platforms

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

Leadtools.Document Assembly

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