IRONSOFTWAREHOME
設置最大平行執行緒數量
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);

Imports IronBarCode
Imports System
Imports System.Collections.Generic
Imports System.Threading.Tasks

Dim imagePaths As New List(Of String)() From {"sample_a.png", "sample_b.png"}

' Barcode reading options
Dim options As New BarcodeReaderOptions() With {
    .Multithreaded = True,
    .MaxParallelThreads = 4
}

' Read barcode with multithreaded enabled
Dim results As BarcodeResults = BarcodeReader.Read(imagePaths, options)
NuGet Download
PM > Install-Package BarCode
設置最大平行執行緒數量

設置最大平行執行緒數量

依序處理大量文件或圖像可能會耗時,並在高需求應用中造成瓶頸。 使用平行執行緒允許應用程式同時處理多個圖像,顯著減少整體執行時間。在本程式碼範例中,我們將示範如何配置IronBarcode以使用多執行緒來加快條碼批次讀取。

使用平行執行緒讀取條碼的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 也將MaxDegreeOfParallelism屬性設置為4,指示讀取器使用最多4個同時執行緒,同時平衡性能與系統資源使用。 MaxParallelThreads MaxParallelThreads Read BarcodeReader.Read

最後,調用BarcodeResults。

學習如何使用IronBarcode設定最大平行執行緒

準備好開始了嗎?

Nuget Downloads 2,472,280版本:2026.10剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰。

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronBarcode
預訂您的免費即時演示
Booking Badge

全球數百萬工程師信賴

Iron Software的客戶標誌
獲取您的無義務諮詢
您的詳細資訊將始終保密。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
全球數百萬工程師信賴
立即獲取您的30天試用金鑰。
無需信用卡或帳戶建立
C# NuGet程式庫,用於PDF
通過NuGet安裝

版本: 2026.10

PM > Install-Package BarCode
nuget.org/packages/BarCode/
  1. 在解決方案資源管理器中,右鍵點擊References,管理NuGet包
  2. 選擇瀏覽並搜尋"IronBarCode"
  3. 選擇包並安裝
C# PDF DLL
下載DLL

版本: 2026.10

  1. 下載並解壓IronBarCode至您的Solution目錄中的~/Libs等位置
  2. 在Visual Studio解決方案資源管理器中右鍵點擊References,選擇瀏覽,"IronBarCode.dll"

從$999起的授權費用