C# 调用LocalPrintServer';s GetPrintQueues挂起

C# 调用LocalPrintServer';s GetPrintQueues挂起,c#,wpf,printing,freeze,C#,Wpf,Printing,Freeze,为了获得可用打印机的列表,我使用以下代码: new LocalPrintServer().GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections }); 在过去,这段代码工作得很好,但现在它挂起在GetPrintQueues调用上 这可能是什么原因造成的?无论是什么问题,似乎都已自行解决,因此,可能是打印后台处理程序本身存在一些问题 我还发现,

为了获得可用打印机的列表,我使用以下代码:

new LocalPrintServer().GetPrintQueues(new[] { 
    EnumeratedPrintQueueTypes.Local, 
    EnumeratedPrintQueueTypes.Connections });
在过去,这段代码工作得很好,但现在它挂起在GetPrintQueues调用上


这可能是什么原因造成的?

无论是什么问题,似乎都已自行解决,因此,可能是打印后台处理程序本身存在一些问题

我还发现,因为我只需要打印机名称,所以速度稍微快一点:

new LocalPrintServer().GetPrintQueues(
   new[] { PrintQueueIndexedProperty.Name, 
       PrintQueueIndexedProperty.Location, PrintQueueIndexedProperty.ShareName },
   new[] { EnumeratedPrintQueueTypes.Local, 
       EnumeratedPrintQueueTypes.Connections });

我不确定您通过此调用获得的所有信息,但在System.Drawing.Printing下,您可以使用
PrinterSettings.InstalledPrinters
获取已安装打印机名称的字符串集合。看起来很快。是的,我最终换了。如果将
GetPrintQueues
EnumeratedPrintQueueTypes.Connections
一起使用,并且无法访问任何网络服务器,则需要很长时间才能返回。不确定这是否是我在这里遇到的问题。