1

I have the following piece of code which gets the list of installed printers into a combobox:

    For Each s As String In Printing.PrinterSettings.InstalledPrinters
        edtPrinter.Items.Add(s)
    Next

However I have a problem with a single client install, probably with the spool service, where this iteration hangs and locks up my app. I can trigger the same "hang" in explorer by clicking on "Devices and Printers" in Control Panel on that particular computer. Restarting Spool32 causes the app to free up until the iteration is hit again.

Rather than fix their spooler problem, how best to implement some kind of timeout or otherwise prevent this call from freezing my app if there is a spooler problem? I can't really call this on a separate thread without difficulty - is there a better way to call this property without exposing my app to the freeze?

Molloch
  • 2,261
  • 4
  • 29
  • 48

1 Answers1

0

One possibility: Sometimes Windows crashes when accessing Windows printing functions on a machine with no printers installed. Make sure your client has at least one printer installed.

xpda
  • 15,585
  • 8
  • 51
  • 82
  • 1
    I fixed the initial problem - a corrupt print driver. The problem is a corrupt print driver caused my app to become unresponsive and this reflects badly on my app - no amount of convincing - including showing the user that the same thing happened in Windows Explorer - would convince them otherwise as they "saw it happen first" in my app. – Molloch Nov 05 '12 at 05:20