Call to LocalPrintServer's GetPrintQueues hangs
In order to get a list of the available printers, I am using the following code:
new LocalPrintServer().GetPrintQueues(new[] {
EnumeratedPrintQueueTypes.Local,
EnumeratedPrintQueueTypes.Connections });
In the past this c开发者_开发百科ode worked fine, but now it hangs on the GetPrintQueues call.
What might cause this?
Whatever the issue was seems to have resolved itself, so perhaps there was some problem with the print spooler that worked itself out.
I also found that, since I only need the printer names, this is slightly faster:
new LocalPrintServer().GetPrintQueues(
new[] { PrintQueueIndexedProperty.Name,
PrintQueueIndexedProperty.Location, PrintQueueIndexedProperty.ShareName },
new[] { EnumeratedPrintQueueTypes.Local,
EnumeratedPrintQueueTypes.Connections });
精彩评论