hello all, I am using the following code to disable/enable the lan card:
and this code is running fine, but whenever I am enabling the RRAS (Routing and Remote Access) from services.msc or via registry or via process in c#, disabling and enabling the adapter takes a long long time...how to solve the problem?
SelectQuery wmiQuery = new SelectQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionId != NULL"); ManagementObjectSearcher searchProcedure = new ManagementObjectSearcher(wmiQuery); foreach (ManagementObject item in searchProcedure.Get()) { if (((string)item["NetConnectionId"]) == interfaceName) { switch (newState) { case 0: item.InvokeMethod("Disable", null); richTextBox1.Invoke((Action)(() => { richTextBox1.AppendText("\nAdapter was disabled"); })); break; case 1: item.InvokeMethod("Enable", null); richTextBox1.Invoke((Action)(() => { richTextBox1.AppendText("\nAdapter was enabled\n"); })); Thread.Sleep(2000); netmon(); break; } } }
and this code is running fine, but whenever I am enabling the RRAS (Routing and Remote Access) from services.msc or via registry or via process in c#, disabling and enabling the adapter takes a long long time...how to solve the problem?