最大並列スレッドの設定
using IronBarCode;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

List<string> imagePaths = new List<string>() { "sample_a.png", "sample_b.png" };

// Barcode reading options
BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Set Max threads to 4
    Multithreaded = true,
    MaxParallelThreads = 4,
};

// Read barcode with multithreaded enabled
BarcodeResults results = BarcodeReader.Read(imagePaths, options);

NuGet Download
PM > Install-Package BarCode
最大並列スレッドの設定

最大並列スレッドの設定

大量の文書や画像を連続して処理するのは時間がかかり、大量のアプリケーションでボトルネックになることがあります。 並列スレッドを使用することで、アプリケーションは複数の画像を同時に処理でき、全体の実行時間を大幅に短縮できます。このコード例では、バーコードのバッチ読み取りを高速化するためにIronBarcodeをマルチスレッドに設定する方法を説明します。

並列スレッドを使用して BarCode を読み取るための 5 つのステップガイド

  • using IronBarCode;
  • using System.Threading.Tasks;
  • List<string> imagePaths = new List<string>() { "sample_a.png", "sample_b.png" };
  • BarcodeReaderOptions options = new BarcodeReaderOptions(){ Multithreaded = true, MaxParallelThreads = 4 };
  • BarcodeResults results = BarcodeReader.Read(imagePaths, options);

コードの説明

まず、IronBarcodeライブラリとスレッドネームスペースをインポートし、処理する画像のファイルパスを含むList<string>を定義します。 上記の例では、"sample_a.png"と"sample_b.png"がスキャン用に用意されています。

次に、スキャン動作を設定するためのBarcodeReaderOptionsオブジェクトをインスタンス化します。 Multithreaded さらに、並列処理を有効にするために、ParallelProcessingプロパティをtrueに設定します。 Multithreaded また、パフォーマンスとシステムリソース使用のバランスをとりながら、最大4つの同時スレッドを使用するようにMaxDegreeOfParallelismプロパティを4に設定します。 MaxParallelThreads MaxParallelThreads Read BarcodeReader.Read

最後に、画像パスのリストと設定されたオプションの両方を渡してBarcodeResultsを取得します。

IronBarcodeで最大並列スレッドを設定する方法を学ぶ

準備はできましたか?

Nuget Downloads 2,540,041バージョン:2026.11リリースされたばかり