ByteScout Barcode Reader SDK - C# - Parallel Barcode Decoding - ByteScout

ByteScout Barcode Reader SDK – C# – Parallel Barcode Decoding

  • Home
  • /
  • Articles
  • /
  • ByteScout Barcode Reader SDK – C# – Parallel Barcode Decoding

parallel barcode decoding in C# using ByteScout BarCode Reader SDK

parallel barcode decoding in C#

These source code samples are listed and grouped by their programming language and functions they use. Parallel barcode decoding in C# can be implemented with ByteScout BarCode Reader SDK. ByteScout BarCode Reader SDK is the SDK for reading of barcodes from PDF, images and live camera or video. Almost every common type like Code 39, Code 128, GS1, UPC, QR Code, Datamatrix, PDF417 and many others are supported. Supports noisy and defective images and docs. Includes optional documents splitter and merger for pdf and tiff based on found barcodess. Batch mode is supported for superior performance using multiple threads. Decoded values are easily exported to JSON, CSV, XML and to custom format.

The SDK samples like this one below explain how to quickly make your application do parallel barcode decoding in C# with the help of ByteScout BarCode Reader SDK. To do parallel barcode decoding in your C# project or application you may simply copy & paste the code and then run your app! Code testing will allow the function to be tested and work properly with your data.

Our website provides free trial version of ByteScout BarCode Reader SDK. It comes along with all these source code samples with the goal to help you with your C# application implementation.

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 BarCode Reader SDK Home Page

Explore ByteScout BarCode Reader SDK Documentation

Explore Samples

Sign Up for ByteScout BarCode Reader SDK 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 BarCode Reader SDK Home Page

Explore ByteScout BarCode Reader SDK Documentation

Explore Samples

Sign Up for ByteScout BarCode Reader SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next