Sebastian Xavier
Sebastian Xavier

Reputation: 2619

handling ManagementScope.timeout in c#

The following code is used for connecting to a remote (WMI) Object using system.management.ManagementScope (C#).

mgmtScope = new ManagementScope("\\\\" + strHostAddress + "\\" + WMIConnection.dictWMINamespace[nameSpace] + "", connOptions); 
string WMITimeOut = ConfigurationManager.AppSettings["WMIConnectionTimeout"];
TimeSpan wmiTimeOutts;
int value;
if (int.TryParse(WMITimeOut, out value))
{
    wmiTimeOutts = new TimeSpan(0, 0, value);
}
else
{
    wmiTimeOutts = new TimeSpan(0, 0, 60);
}

mgmtScope.Options.Timeout = wmiTimeOutts;
mgmtScope.Connect();

Recently I have added code for timeout. Now I want to do some actions when a request timeout occurs.

Not sure how to find out whether the request has been timed out or not. Any help on this would be greatly appreciated.

Regards Sebastian

Upvotes: 0

Views: 1012

Answers (1)

James L
James L

Reputation: 16874

The Timeout property is intended for 'semi-synchronous' enumeration of results. It will not detect a connection timeout.

See here for more information

Upvotes: 1

Related Questions