LoadFromUriAsync Method (original) (raw)

Summary

Loads a document asynchronously from existing data stored in a remote URL.

Syntax

Parameters

uri

Path to the URL containing the original document data. This value cannot be null.

options

Options to use when loading the document. This value cannot be null.

Example

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(); }