Thread Safe?

Questions about PDF creation DLL
gregsohl
Posts: 19
Joined: Thu Jul 28, 2005 7:28 pm

Thread Safe?

Postby gregsohl » Fri Aug 05, 2005 2:35 pm

Are the .NET wrapper and the PDF control itself thread safe? The license we own is:

PDFControl V2.35
SITE License

Thanks.

wpsupport
Site Admin
Posts: 7369
Joined: Fri Oct 24, 2003 4:06 pm
Contact:

Postby wpsupport » Mon Aug 08, 2005 12:34 pm

Hi,

the wrapper uses threadsave abstractions. The C# code is also included.

Julian

gregsohl
Posts: 19
Joined: Thu Jul 28, 2005 7:28 pm

Postby gregsohl » Mon Oct 31, 2005 4:12 am

How about the ActiveX Control itself when used via the .NET wrapper? The documentation for the ActiveX control says:

"Plaese note that the DLL can currently not work multithreaded."

Greg

gregsohl
Posts: 19
Joined: Thu Jul 28, 2005 7:28 pm

Postby gregsohl » Mon Oct 31, 2005 4:36 pm

When I'm using it in a multi-threaded environment, with multiple PDF's being generated at once, each thread with its own instance of the .NET wrapper class, I'm getting occasional exceptions which I'm having trouble finding any reason for. The exception is:

Code: Select all

Object reference not set to an instance of an object.
   at wPDF.wPDFControlDLL.EndPage(Int32 env)
   at wPDF.wPDFControlWrap.EndPage(Int32 env)
   at wPDF.PDFControl.EndPage()
   at Mynamespace.Printing.PdfPrintController.OnEndPage(PrintDocument document, PrintPageEventArgs e)
   at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
   at System.Drawing.Printing.PrintController.Print(PrintDocument document)
   at System.Drawing.Printing.PrintDocument.Print()
   at Mynamespace.PrintIdentifiersPDF.Print()


Any ideas what would cause this? I've never had this happen in a single threaded use. Thanks.

gregsohl
Posts: 19
Joined: Thu Jul 28, 2005 7:28 pm

Postby gregsohl » Mon Oct 31, 2005 8:37 pm

... and in my last multi-threaded test run, the following exception:

Code: Select all

Object reference not set to an instance of an object.
   at wPDF.wPDFControlDLL.DrawMetafile(Int32 env, IntPtr meta, Int32 x, Int32 y, Int32 w, Int32 h, Int32 xres, Int32 yres)
   at wPDF.wPDFControlWrap.DrawMetafile(Int32 env, IntPtr meta, Int32 x, Int32 y, Int32 w, Int32 h, Int32 xres, Int32 yres)
   at wPDF.PDFControl.CloseCanvas()
   at wPDF.PDFControl.EndPage()
   at MyNamespace.PdfPrintController.OnEndPage(PrintDocument document, PrintPageEventArgs e) in D:\mysource\PdfPrintController.cs:line 48
   at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
   at System.Drawing.Printing.PrintController.Print(PrintDocument document)
   at System.Drawing.Printing.PrintDocument.Print()
   at MyNamespace.PrintIdentifiersPDF.Print() in d:\mysource\printidentifierspdf.cs:line 117

stffabi
Posts: 8
Joined: Tue Jul 26, 2005 2:04 pm

Postby stffabi » Thu Nov 03, 2005 5:11 pm

Same here sometimes, I get the exception that the page couldn't be started because there wasn't a begindoc call. but the call was there, and somethimes it just works fine.

It would be nice if there would be a bugfix for this soon.

stffabi
Posts: 8
Joined: Tue Jul 26, 2005 2:04 pm

Postby stffabi » Wed Nov 09, 2005 5:19 pm

Hi Julian

If you could take a look into that, that would be great.

Regards
Fabrizio

wpsupport
Site Admin
Posts: 7369
Joined: Fri Oct 24, 2003 4:06 pm
Contact:

Postby wpsupport » Fri Nov 11, 2005 10:36 am

Hi,

the DLL itself (the code) is actually threadsave but there are problems with the loading/unloading of DLLs in threads. I actually don't know how to overcome this in .NET. Technically there should be no problem.

Julian Ziersch

stffabi
Posts: 8
Joined: Tue Jul 26, 2005 2:04 pm

Postby stffabi » Fri Nov 11, 2005 4:24 pm

Hi Julian

I've taken a look into the c# source code of the wrapper class. The problem I found out, are the calls from the wPDFControlWrap calls to the static wPDFControlDLL class. Only one thread could actually call a function on the static wPDFControlDLL, that goes to the wpdfControl02.dll. I synchronized the calls and now everything works just fine. Tried 1000 loops with 4-10 threads without any problem.

If you would like I can send you the modified code of the wPDFControlWrap and wPDFControlDLL class by mail?

Kind Regards
Fabrizio

gregsohl
Posts: 19
Joined: Thu Jul 28, 2005 7:28 pm

Postby gregsohl » Fri Nov 11, 2005 4:29 pm

Can you at least post the details here. I'd very much appreciate knowing your solution.

wpsupport
Site Admin
Posts: 7369
Joined: Fri Oct 24, 2003 4:06 pm
Contact:

Postby wpsupport » Sun Nov 13, 2005 6:59 am

Hi stffabi,

Yes, please send me that code. I will post it in an update.

Julian

stffabi
Posts: 8
Joined: Tue Jul 26, 2005 2:04 pm

Postby stffabi » Tue Nov 15, 2005 7:23 am

Hi Julian

I've sent the source code by email to you.

Kind Regards
Fabrizio

NetDeveloper
Posts: 6
Joined: Thu Mar 02, 2006 10:21 pm

Postby NetDeveloper » Thu Mar 02, 2006 10:37 pm

Has the new syncronization code been added to wPDF file version 2.7 (NET20)? I am running into similar issues while multiple threads are creating PDFs at the same time. Runs for a while and then all threads get exceptions such as:

Thread1 gets:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

while in

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at wPDF.wPDFControlDLL.DrawMetafile(Int32 env, IntPtr meta, Int32 x, Int32 y, Int32 w, Int32 h, Int32 xres, Int32 yres)
at wPDF.wPDFControlWrap.DrawMetafile(Int32 env, IntPtr meta, Int32 x, Int32 y, Int32 w, Int32 h, Int32 xres, Int32 yres)
at wPDF.PDFControl.CloseCanvas()
at wPDF.PDFControl.EndPage()

and on the other thread I get:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at wPDF.wPDFControlDLL.StartPage(Int32 env, Int32 Width, Int32 Height, Int32 Rotation)
at wPDF.wPDFControlWrap.StartPage(Int32 env, Int32 Width, Int32 Height, Int32 Rotation)
at wPDF.PDFControl.StartPage(Int32 w, Int32 h, Boolean landscape)
at wPDF.PDFControl.StartPage(ePage format, Boolean landscape)
at wPDF.PDFControl.StartPage()

Thank you for any help on this!! :)

wpsupport
Site Admin
Posts: 7369
Joined: Fri Oct 24, 2003 4:06 pm
Contact:

Postby wpsupport » Fri Mar 10, 2006 7:40 am

The DLL uses new internal code to solve this issue.

I will investigate this further.

Julian

wpsupport
Site Admin
Posts: 7369
Joined: Fri Oct 24, 2003 4:06 pm
Contact:

Re: Thread Safe?

Postby wpsupport » Mon Jun 20, 2016 8:48 pm

wPDFControl 4 comes with a new deme to test the multi threaded PDF creation. Several optimations were integrated in the new version.


Return to “wPDFControl/RTF2PDF”



Who is online

Users browsing this forum: No registered users and 2 guests