ByteScout Data Extraction Suite - C# - Parallel barcode decoding with barcode reader sdk - ByteScout

ByteScout Data Extraction Suite – C# – Parallel barcode decoding with barcode reader sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Data Extraction Suite – C# – Parallel barcode decoding with barcode reader sdk

parallel barcode decoding with barcode reader sdk in C# using ByteScout Data Extraction Suite

parallel barcode decoding with barcode reader sdk in C#

This page explains the steps and algorithm of implementing parallel barcode decoding with barcode reader sdk and how to make it work in your application. Parallel barcode decoding with barcode reader sdk in C# can be applied with ByteScout Data Extraction Suite. ByteScout Data Extraction Suite is the bundle that includes three SDK tools for data extraction from PDF, scans, images and from spreadsheets: PDF Extractor SDK, Data Extraction SDK, Barcode Reader SDK.

The below SDK samples describe how to quickly make your application do parallel barcode decoding with barcode reader sdk in C# with the help of ByteScout Data Extraction Suite. Just copy and paste this C# sample code to your C# application’s code editor, add a reference to ByteScout Data Extraction Suite (if you haven’t added yet) and you are ready to go! This basic programming language sample code for C# will do the whole work for you in implementing parallel barcode decoding with barcode reader sdk in your app.

Visit our website to get a free trial version of ByteScout Data Extraction Suite. Free trial contains many of source code samples to help you with your C# project.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System; using System.IO; using System.Threading; using Bytescout.BarCodeReader; namespace ParallelDecoding { class Program { const string InputFile = @".\example.pdf"; // Limit to 4 threads in queue. // Set this value to number of your processor cores for max performance. private static readonly Semaphore ThreadLimiter = new Semaphore(4, 4); static void Main() { const int numberOfRuns = 10; ManualResetEvent[] doneEvents = new ManualResetEvent[numberOfRuns]; for (int i = 0; i < numberOfRuns; i++) { // Wait for the queue ThreadLimiter.WaitOne(); doneEvents[i] = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object state) { int threadIndex = (int) state; Console.WriteLine("Thread #" + threadIndex + " started..."); try { Reader reader = new Reader(); reader.RegistrationName = "demo"; reader.RegistrationKey = "demo"; // Set barcode type to find reader.BarcodeTypesToFind.Code128 = true; /* ----------------------------------------------------------------------- NOTE: We can read barcodes from specific page to increase performance. For sample please refer to "Decoding barcodes from PDF by pages" program. ----------------------------------------------------------------------- */ // Read barcodes FoundBarcode[] barcodes = reader.ReadFrom(InputFile); Console.WriteLine("Thread #" + threadIndex + " finished with " + barcodes.Length + " barcodes found."); // Cleanup reader.Dispose(); } catch (Exception exception) { Console.WriteLine("Thread #" + threadIndex + " failed with exception:\r\n" + exception.Message); } finally { // Signal the thread is finished doneEvents[threadIndex].Set(); // Release semaphore ThreadLimiter.Release(); } }), i); } WaitHandle.WaitAll(doneEvents); Console.WriteLine("All threads done."); Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next