WMI Access - Help
-
Ive been battling with this prob for a LONG time now.. Using Threads and remote retrieval: i get a rpc error or COm exception sometimes? Like it's retrieving the values, and then it says rpc server unavailable and then if u carry on it will retrieve the next value.. happens with different values.. maybe deadlock occurs? Basically- i use: private ManagementObjectSearcher m_MOSearcher; private ManagementScope m_ManScope; private ConnectionOptions m_ConnectOptions; m_ConnectOptions = new ConnectionOptions (); m_ConnectOptions.Username = "user"; m_ConnectOptions.Password = "pass"; m_ConnectOptions.Authentication = AuthenticationLevel.Call; m_ConnectOptions.Impersonation = ImpersonationLevel.Impersonate; m_ConnectOptions.EnablePrivileges = true; m_ConnectOptions.Locale = "MS_409"; m_ConnectOptions.Timeout = new TimeSpan (0,0,0,0,5); string strConnection = "\\\\"+ "192.168.0.88" + "\\root\\cimv2"; m_ManScope = new ManagementScope(strConnection, m_ConnectOptions); ObjectQuery Temp = new ObjectQuery("SELECT " + "Size" + " FROM Win32_" + "DiskDrive"); m_MOSearcher = new ManagementObjectSearcher (m_ManScope, Temp); foreach(ManagementObject mo in m_MOSearcher.Get()) { Console.WriteLine("Size: " +mo["Size"].ToString ()); } Temp = new ObjectQuery("SELECT " + "Model" + " FROM Win32_" + "DiskDrive"); m_MOSearcher = new ManagementObjectSearcher (m_ManScope, Temp); foreach(ManagementObject mo in m_MOSearcher.Get()) { Console.WriteLine("Model: " +mo["Model"].ToString ()); } And thread it with: for (int i=0; i< 250; i++) { Thread a = new Thread(new ThreadStart(Function)); a.Start(); }