Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,

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

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( see the underlined part). 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
Posted

1 solution

Looks like you got your answer: http://stackoverflow.com/questions/24887018/handling-managementscope-timeout-in-c-sharp[^]

Perhaps a try catch will work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900