StartDoc error 87 with multiple threads

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
rec
Posts: 19
Joined: Tue Feb 21 2006

StartDoc error 87 with multiple threads

Post by rec »

Amyuni v2.50g

I have an application that uses multiple threads to create PDF files using the Amyuni driver. However, if I attempt to create lots of files simultaneously (by having multiple threads access the Amyuni driver at the same time) I am occasionally having ::StartDoc fail with GetLastError returning code 87 ('the parameter is incorrect'). The application handle count seems reasonable (less than 1,000) and if I add experimental code to lock access to the driver (using a critical section) so only one thread can use the driver at a time, then the problem goes away. However, locking access like this affects performance and if I use a 'normal' Windows printer driver instead, the problem doesn't occur.

Is there a limit to how many threads can open the Amyuni printer driver? Will v3 (which I have but have yet to try) help?

Any advice would be welcome. At the moment I am considering adding some code that sets a limit on the number of concurrent threads that can access the driver, locking when some magic value is reached.
rec
Posts: 19
Joined: Tue Feb 21 2006

Post by rec »

FWIW I am using standard Windows printing API calls to create PDFs. The PDF filename is set via DOCINFO, and there are no calls to SetDefaultFileName or SetDefaultDirectory. Hence I assume there shouldn't be any need to call any special locking functions.
rec
Posts: 19
Joined: Tue Feb 21 2006

Post by rec »

Just tried v3 and it's the same - I still get errors when lots of threads try to access the driver at the same time.
rec
Posts: 19
Joined: Tue Feb 21 2006

Post by rec »

OK, I finally got to the bottom of this - the Amyuni driver was creating lots of GDI handles and eventually all handles were exhausted. I have now implemented some locking code to limit the number of threads that can access the driver, and this seems to have fixed the problem. So the Amyuni driver is working as expected.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

In mutithreading environments you need to use the locking mechanisme of CDintf or any other locking functions for the jobs not to be overwritten.
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
Post Reply