使用WMI查询“Win32_Printjob”收集所有printjobs。花了很多时间。还有其他选择吗? [英] Collecting all printjobs with WMI query "Win32_Printjob" is taking a lot of time.Any alternatives?

查看:422
本文介绍了使用WMI查询“Win32_Printjob”收集所有printjobs。花了很多时间。还有其他选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我使用ManagementObjectSearcher类并使用查询," SELECT * FROM Win32_PrintJob"获取所有打印作业。但是枚举所有printjob需要花费很多时间。还有其他方法可以枚举这些printjob.How我可以直接使用Win32 API来枚举这些printjob



//我用来获取所有printjob的代码片段,这会导致问题(很长时间)


string query =" SELECT * FROM Win32_PrintJob"


ManagementObjectsearcher search = new ManagementObjectsearcher (查询);


ManagementObjectCollection collection = search.Get();



帮我看看解决它。任何建议或解决方案对我都有很大的帮助。


谢谢,


解决方案

所需的时间取决于在任何给定时间连接的打印机上的内容。我使用的方法是创建一个ManagementEventWatcher,它允许您接收新到达的打印作业的异步通知,但您可能需要一种不同的方法,具体取决于您实际要对打印作业执行的操作。此代码构成了我正在构建的应用程序中的类的一部分,它监视打印机并要求最终用户确认打印作业并为每个Jop打印收费。





创建事件观察器结果

 

I use ManagementObjectSearcher class and using the query ,"SELECT * FROM Win32_PrintJob" to get all print job.But enumerating all printjob is taking lot of time.Is there any other ways to enumerate these printjob.How can i directly use the Win32 API to enumerate thses printjob

 

//code snippet which i am using to get all the printjob, and it's causing problem(taking a long time)

string query = "SELECT * FROM Win32_PrintJob"

ManagementObjectsearcher search = new ManagementObjectsearcher(query);

ManagementObjectCollection collection =  search.Get();

 

Help me to solve it out.Any suggestion or solution will be of great help for me.

Thanks,

 

解决方案

The time it takes will depend on how much stuff is on connected Printers at any given time.  The approach I use is to create a ManagementEventWatcher which allows you to receive Asynchronous notification of newly arrived Print Jobs, though you may need a different approach depending on what you actually want to do with the Print Jobs.  This code forms part of a class in an Application I'm building which Monitors Printers and required End Users to Confirm Print Jobs and Charges them for each Jop Printed.

Creating the Event Watcher


这篇关于使用WMI查询“Win32_Printjob”收集所有printjobs。花了很多时间。还有其他选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆