←Select platform

IsCancelPending Property

Summary

Aborts the load operation.

Syntax
C#
C++/CLI
Python
public bool IsCancelPending {get; set;} 
public:  
   property bool IsCancelPending 
   { 
      bool get() 
      void set(bool value) 
   } 
IsCancelPending # get and set (LoadAsyncProgressEventArgs) 

Property Value

true to abort the current load operation; otherwise, false. Default value is false.

Remarks

Progress can be used to show a progress bar indicator for the user while the factory is loading a document. In this scenario, it is sometimes preferable to allow the user to abort the load operation (for example, through a Cancel button in the UI). Set IsCancelPending to true to gracefully abort load thread and cancel the load operation.

After the operation is aborted, the value of System.ComponentModel.AsyncCompletedEventArgs.Cancelled of the LoadDocumentAsyncOptions.Completed event data will be set to true and the value of Document will be null.

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.