private static void Main() { NetworkMonitor.StateChanged += NetworkMonitor_StateChanged; NetworkMonitor.StartMonitor(); Console.WriteLine("Press any key to stop monitoring."); Console.ReadKey(); NetworkMonitor.StopMonitor(); Console.WriteLine("Press any key to close program."); Console.ReadKey(); }
private bool TestedeRedeLocal() { NetworkMonitor.StateChanged += (object sender, StateChangeEventArgs e) => { if (e.IsAvailable == false) { EventoAoFalharRede("A conexão de rede deste computador está indisponível"); } }; NetworkMonitor.StartMonitor(); Thread.Sleep(1000); return(NetworkMonitor.CurrentState); }
static SystemInfo() { var mc = new ManagementClass("Win32_ComputerSystem"); var moc = mc.GetInstances(); foreach (var mo in moc) { if (mo["TotalPhysicalMemory"] != null) { PhysicalMemory = long.Parse(mo["TotalPhysicalMemory"].ToString()); } } networkMonitor.StartMonitor(); }