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?