多线程生成
IronPDF 使用 2021 Chrome Rendering API 提供广泛的多线程支持。
.NET中的线程方法包括
- System.Threading.Tasks (低于)
async/await
- Parallel.ForEach
using IronPdf; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; // Instantiate Renderer var renderer = new ChromePdfRenderer(); var htmlStrings = new List<string>() { "<h1>Html#1</h1>", "<h1>Html#2</h1>", "<h1>Html#3</h1>" }; Task<PdfDocument[]> task = Task.WhenAll(htmlStrings.Select(html => renderer.RenderHtmlAsPdfAsync(html))); List<PdfDocument> pdfList = task.Result.ToList(); // Do something with the pdfDocuments
Imports IronPdf Imports System.Collections.Generic Imports System.Linq Imports System.Threading.Tasks ' Instantiate Renderer Private renderer = New ChromePdfRenderer() Private htmlStrings = New List(Of String)() From {"<h1>Html#1</h1>", "<h1>Html#2</h1>", "<h1>Html#3</h1>"} Private task As Task(Of PdfDocument()) = System.Threading.Tasks.Task.WhenAll(htmlStrings.Select(Function(html) renderer.RenderHtmlAsPdfAsync(html))) Private pdfList As List(Of PdfDocument) = task.Result.ToList() ' Do something with the pdfDocuments
Install-Package IronPdf
IronPDF 使用 2021 Chrome Rendering API 提供广泛的多线程支持。
.NET中的线程方法包括
async/await