多线程生成
IronPDF支持使用2021 Chrome渲染API的广泛多线程。
.NET 中的多线程方法包括:
- System.Threading.Tasks(低于)
- 异步/等待
- 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渲染API的广泛多线程。
.NET 中的多线程方法包括: