I've inherited code that makes numerous remote WMI calls. When I repeatedly pause execution and look at the call-stack it's almost always in a ManagementScope.Connect()
call. A new connection seems to be made with each WQL query.
Despite limited trial and error, I haven't found any big wins yet in improving the performance of the WMI calls.
I've tried caching previous results, reusing connections, and avoiding the dreaded "select *
". These haven't given me the performance improvements that I'd like. I'm interested to understand the impact of environment on WMI performance, but the code needs to run in a wide variety of environments that are probably beyond my control.
If any, what are the do's and don't's of performance oriented WMI access in .NET?