Aspose.PDF in a multithreaded windows service


#1

Hi! I am a new here. First let me say, I really like working with your product, and found it extremely easy to use! I did have a quick question though. I am incorporating the Aspose.PDF library into a windows service I am writing to handle the creation of PDF mailing labels (and data exports) for my company’s web application. Its purpose is to monitor a queue and handle jobs that get submitted by the web application, and notify the end user of the jobs completion so the resulting file may be downloaded. The main thread of the windows service its self maintains a thread pool, and assigns each job to a thread to be handled. Through testing, I noticed that I occasionally fail when multiple PDF creations are happening, and I was curious if Aspose.PDF is thread safe? When I restrict the service to a single thread, the errors disappear. Specifically, this is the exception I am catching:

Work Thread (JID#98) : Error creating export file.System.ComponentModel.Win32Exception: The operation completed successfully
at System.Drawing.Font.ToHfont()
at eo.a(fj A_0, String A_1, Int32 A_2, Boolean A_3, Boolean A_4, String A_5, Boolean A_6)
at eo.a(fj A_0, String A_1, String A_2, Int32 A_3, Int32 A_4, Boolean A_5, Boolean A_6, Boolean A_7, String A_8, Boolean A_9)
at n.a(fj A_0, Int32 A_1, String A_2, Int32 A_3, String A_4, Int32 A_5, Boolean A_6, Boolean A_7, String A_8, Boolean A_9)
at dk.a(fj A_0, String A_1, String A_2, Int32 A_3, Boolean A_4, Boolean A_5, String A_6, Boolean A_7)
at fj.a(String A_0, String A_1, String A_2, String A_3, Int32 A_4, Boolean A_5, Boolean A_6, String A_7, Boolean A_8)
at e2.a(Pdf A_0, Section A_1, Table A_2, Row A_3, Cell A_4, Text A_5, String A_6, a A_7, cn A_8)
at ch.a(Pdf A_0, Section A_1, Table A_2, Row A_3, Cell A_4, Text A_5, a A_6, cn A_7, Boolean A_8)
at bv.a(Pdf A_0, Section A_1, Table A_2, Row A_3, Cell A_4, a A_5)
at dz.a(Pdf A_0, Section A_1, Table A_2, Row A_3, a A_4)
at bt.a(Pdf A_0, Section A_1, Table A_2, a A_3, Boolean A_4)
at cd.a(Pdf A_0, Section A_1, a A_2)
at bs.a(Pdf A_0)
at an.a(az A_0, Pdf A_1)
at Aspose.Pdf.Pdf.Save(String pdfFile)
at ExportQueueManager.ExportEngine.CreateDataFile_A5160(DataTable& oDataTable, String& FileName, String& VirtualPath, Int32& ExportedCount) in C:\Trend\RealtyRecords\ExportQueueManager\ExportEngine.vb:line 517
at ExportQueueManager.ExportEngine.ProcessExport() in C:\Trend\RealtyRecords\ExportQueueManager\ExportEngine.vb:line 183


Line 517 which fails: oPDF.Save(sPhysicalPath)

Thanks for your input in advance!


#2

Dear Jason,

Thanks for your consideration.

There is really some error with Aspose.Pdf when used in multi-thread. I will try to solve this problem. But I think it need much time.



#3

Thats fine. Thanks for your help still! For now, I am just forcing any PDF creations to a single thread. I was more just curious so I knew which direction to take my code in :-). Later!