Callback to get the fileName to run the AutoFormsEngine on.
public delegate void AutoFormsParallelRunItemGetterFileName(
ref string fileName,
ref object itemUserData,
ref string repositoryName,
object getterUserData
)
fileName
Path of the file to run the AutoFormsEngine on it.
itemUserData
Optional object associated with the input item.
repositoryName
If the corresponding repository name of item is not null, then AutoFormsParallelRunItemGetterFileName uses it in place of the current value of FullTextSearchRepositoryName.
getterUserData
Optional object that might be passed to the RunParallelPipesOnDemand and then passed to the getter callback.
If the getterUserData is used, then apply an appropriate syncing method as multiple getters can be called in parallel threads.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms.Common;
using Leadtools.Forms.Auto;
using Leadtools.Document;
using Leadtools.Ocr;
using Leadtools.Forms.Recognition;
using Leadtools.Forms.Processing;
using Leadtools.Barcode;
using Leadtools.Forms;
public void ResultCallback1(string fileName, AutoFormsRunResult result, int itemIndex, object label)
{
if (result == null)
{
Console.WriteLine($"ERROR!!!: Failed to process {label}: [{itemIndex}] {fileName}");
}
else
{
Console.WriteLine($"Successfully processed {label}: [{itemIndex}] {fileName}");
foreach (FormPage page in result.FormFields)
{
foreach (FormField field in page)
{
Console.WriteLine($"Process for the field {field.Name} is {field.Result.Status} ");
}
}
}
}
public void ProcessFormsMultiProcessOnDemand(AutoFormsEngine autoEngine, List<string> fileNames, List<string> repositoryNames)
{
int nextItemIndex = -1;
AutoFormsParallelRunItemGetterFileName getter = (ref string file, ref object itemUserData, ref string repositoryName, object getterUserData) =>
{
int index = Interlocked.Increment(ref nextItemIndex);
if (index >= fileNames.Count)
return;
file = fileNames[index];
repositoryName = repositoryNames == null ? null : repositoryNames[index];
};
autoEngine.RunParallelPipesOnDemand(
getter,
null,
ResultCallback1,
8
);
}