Application Hangs When Printing 追蹤

0
Avatar
Legacy Poster

I created a small VB.Net application using the Bartender SDK (DLL version 10.0.4.2868) to print a specific label, and do some data manipulation afterwards. The program works fine when printing to local printers. However, when printing to a remote printer, it will hang. It loads the label and works perfectly until it gets to the .print() subroutine; at that point, it hangs up and sits there forever. No matter how high or low the print timeout is set, it won't return from that routine.

 

Printing to the remote printers using the Print Station works fine.

 

The code in question looks similar to this:

 

Dim eng As Seagull.BarTender.Print.Engine
eng = New Engine(True)
 
Dim timeout As Integer = 10000
Dim messages As Seagull.BarTender.Print.Messages = Nothing
Dim lfd As Seagull.BarTender.Print.LabelFormatDocument = eng.Documents.Open(filename, printername)
Dim result As Seagull.BarTender.Print.Result = eng.ActiveDocument.Print(Me.Name, timeout, messages)
 
What reasons would cause the print SDK to hang?

3 意見

0
Avatar
Michael Toupin (mtoupin
評論操作 永久連結

If it only happens when printing to remote printers it's possible that it's permissions related.  Are you specifying that the application work under a specific user account?

0
Avatar
Legacy Poster
評論操作 永久連結

No, just the standard user account.

I forgot to mention that the labels will actually print before it hangs, and that probably confuses me the most. If the labels print, it can obviously communicate with the server and the printer; it just doesn't return after printing.

0
Avatar
Legacy Poster
評論操作 永久連結

Further analysis shows it may be related to threading; for some reason, invoking the print command in a thread causes a hang. When I remove threading from the program, it functions as it should.

 

I was incorrect, this is not threading related. It turns out, if the timeout is set to 1000, it works as expected; if the timeout is set to 60000, it hangs forever. I've hard-coded the timeout, and it now works as expected.

登入寫評論。