How to set a timeout on WMI queries?

后端 未结 2 1294
醉话见心
醉话见心 2020-12-19 04:22

I have a .NET application which runs WMI queries on all domain computers in order to find the logged in user; it pings each computer to find whether it is online or not, the

相关标签:
2条回答
  • 2020-12-19 04:59

    Try co.Timeout = new TimeSpan(0, 0, 30);

    0 讨论(0)
  • 2020-12-19 05:00

    The ManagementObjectSearcher has an Options property: one of the available options is Timeout, of type TimeSpan:

    Gets or sets the time-out to apply to the operation. Note that for operations that return collections, this time-out applies to the enumeration through the resulting collection, not the operation itself (the ReturnImmediately property is used for the latter). This property is used to indicate that the operation should be performed semi-synchronously.

    0 讨论(0)
提交回复
热议问题