We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Use Aspose.PDF for .NET in multithreaded environment to generate PDF files

Hello, I’m using Aspose.Pdf to generate pdf documents from html in a web service.
Recently I was doing load testing. I was running two concurrent batches of requests and noticed that Aspose.Pdf throws exceptions in various places when two concurrent requests are trying to generate document using different Aspose.Pdf.Pdf class instances.

Found the thread which describes similar issue but increasing the execution time did not help. I attach the log containing exception details and piece of code. Especially “Collection was modified; enumeration operation may not execute.” exceptions might notice that there is something wrong with synchronization.

The sample code attached works. But when I comment out the ,lock (AsposePdf)’’ line the exceptions occur immediately. I verified the same code with Aspose.Pdf as well and found the same problem. Could you give me a hint if I’m doing something wrong?

Thanks in advance.

Hello Tomasz,

Thanks for using our products.

We are working over this query and will get back to you soon. We apologize for your inconvenience.


Please note that Aspose.PDF for .NET is multi-threaded safe API as long as one thread is working with one PDF document at a time. In other words, one PDF document should not be accessed by more than single thread. Please try using latest version of the API and let us know in case you face any issue.