I did some debugging and the GDI handles increase by 30 and never release them each time I print a document. So I am pretty confident that this issue is related to SpirePDF.
When I call pdf.print(), it spawns 30 new handles and when I exit .print(), those handles are still there even when I exit the running thread.
(no specific category shown on GDIView but total number increases)
SpirePdf.dll version: 7.4.13.0
I run this on a background thread. Code:
- Code: Select all
using (PdfDocument pdf = new PdfDocument((filePath + Filename)))
{
try
{
pdf.PrintSettings.PrintController = new StandardPrintController();
pdf.PrintSettings.DocumentName = Filename;
pdf.PrintSettings.PrinterName = settings.ActivePrinter;
pdf.Print();
}
catch
{
// Some error handling.
}
Thread.Sleep(200);
pdf.PrintSettings.Dispose();
pdf.Dispose();
pdf.Close();
}