// USE CASE: Using batch processing events public static void Using_batch_processing_events(IEngine engine) { trace("Open a project..."); IProject project = engine.OpenProject(SamplesFolder + "\\SampleProject\\Invoices_eng.fcproj"); try { trace("Add a new batch..."); IBatch batch = project.Batches.AddNew("TestBatch"); trace("Open the new batch..."); batch.Open(); // Here we create an events sink which will capture batch processing events and // show progress and tracing messages in the status bar. This will also make UI // more responsive to user input. See definition of the sink class for details trace("Start listening to batch processing events..."); SampleBatchEventsSink eventsSink = new SampleBatchEventsSink(batch); try { trace("Add the image files to the batch..."); batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_1.tif"); batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_2.tif"); batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_3.tif"); trace("Recognize the batch..."); batch.Recognize(null, RecognitionModeEnum.RM_ReRecognizeMinimal, null); trace("Export the results..."); batch.Export(null, null); trace("Close and delete the batch..."); } finally { eventsSink.Dispose(); batch.Close(); project.Batches.DeleteAll(); } trace("Close the project..."); } finally { project.Close(); } }
// USE CASE: Using batch processing events public static void Using_batch_processing_events( IEngine engine ) { trace( "Open a project..." ); IProject project = engine.OpenProject( SamplesFolder + "\\SampleProject\\Invoices_eng.fcproj" ); try { trace( "Add a new batch..." ); IBatch batch = project.Batches.AddNew( "TestBatch" ); trace( "Open the new batch..." ); batch.Open(); // Here we create an events sink which will capture batch processing events and // show progress and tracing messages in the status bar. This will also make UI // more responsive to user input. See definition of the sink class for details trace( "Start listening to batch processing events..." ); SampleBatchEventsSink eventsSink = new SampleBatchEventsSink( batch ); try { trace( "Add the image files to the batch..." ); batch.AddImage( SamplesFolder + "\\SampleImages\\Invoices_1.tif" ); batch.AddImage( SamplesFolder + "\\SampleImages\\Invoices_2.tif" ); batch.AddImage( SamplesFolder + "\\SampleImages\\Invoices_3.tif" ); trace( "Recognize the batch..." ); batch.Recognize( null, RecognitionModeEnum.RM_ReRecognizeMinimal, null ); trace( "Export the results..." ); batch.Export( null, null ); trace( "Close and delete the batch..." ); } finally { eventsSink.Dispose(); batch.Close(); project.Batches.DeleteAll(); } trace( "Close the project..." ); } finally { project.Close(); } }