Occurs when a job is completed or aborted.
This event will occur when RunJob or RunJobAsync is finished running.
You can use this event to keep track of the number of jobs pending running. You can also examine DocumentConverterJobEventArgs.Job to get information on whether job finished successfully and get error status if any. RunJob example shows complete source code of how to easily accomplish these tasks in your application.
The JobStarted will occur exactly once per job. DocumentConverterJobEventArgs.IsPostOperation will always be false.
The JobCompleted event will always occur when a job is finished running whether the job is aborted or completed.
The JobStarted event occurs when a job is about to start.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Document.Writer;
using Leadtools.Svg;
using LeadtoolsExamples.Common;
using Leadtools.Document;
using Leadtools.Caching;
using Leadtools.Annotations.Engine;
using Leadtools.Ocr;
using Leadtools.Document.Converter;
using Leadtools.Annotations.Rendering;
public void DocumentConverterJobsRunJobAsyncExample()
{
using (DocumentConverter documentConverter = new DocumentConverter())
{
documentConverter.Diagnostics.EnableTrace = true;
var inFile = Path.Combine(ImagesPath.Path, @"Leadtools.doc");
var outFile = Path.Combine(ImagesPath.Path, @"output.pdf");
var format = DocumentFormat.Pdf;
var jobData = DocumentConverterJobs.CreateJobData(inFile, outFile, format);
jobData.JobName = "conversion job";
var job = documentConverter.Jobs.CreateJob(jobData);
AutoResetEvent finished = null;
EventHandler<DocumentConverterJobEventArgs> completed = null;
completed = (sender, e) =>
{
if (e.Status == DocumentConverterJobStatus.Success)
{
Console.WriteLine("Success");
}
else
{
Console.WriteLine("{0} Errors", e.Status);
foreach (var error in e.Job.Errors)
{
Console.WriteLine(" {0} at {1}: {2}", error.Operation, error.InputDocumentPageNumber, error.Error.Message);
}
}
var thisJobs = sender as DocumentConverterJobs;
thisJobs.JobCompleted -= completed;
finished.Set();
};
documentConverter.Jobs.JobCompleted += completed;
finished = new AutoResetEvent(false);
documentConverter.Jobs.RunJobAsync(job);
finished.WaitOne();
}
}
Parameter | Type | Description |
---|---|---|
sender | object | The source of the event. |
e | DocumentConverterJobEventArgs | The event data. |