使用System.Printing.PrintQueueCollection() 纸质打印机获取
_generalPrinters = new PrintQueueCollection();
public PrintQueueCollection GeneralPrinters
{
get { return _generalPrinters; }
set { _generalPrinters = value; }
}
GeneralPrinters是不允许跨线程调用的。
偶现会提示:“线程无法访问此对象,因为另一个线程拥有该对象”
根源:
PrintQueueCollection 类的构造中有这样一行:
this.accessVerifier = new PrintSystemDispatcherObject();
所以PrintQueueCollection仅其创建线程可用
跨线程调用,需要PrintQueueCollection()新线程重新调用。