/// <summary>Sleep wait for a network interface with a valid (e.g. not 0.0.0.0) IP address</summary> public void WaitForIpAddress( ) { do { StatusChanged.Reset(); foreach (var itf in NetworkInterfaces) { if (itf.IPAddress == "0.0.0.0" || itf.IPAddress == "127.0.0.1") { continue; } Debug.Print("Found IP: " + itf.IPAddress); /*Debug.Print( " MAC: " + itf.PhysicalAddress[ 0 ] + ":" + ((uint)itf.PhysicalAddress[ 1 ]).ToString( "X" ) + ":" + ((uint)itf.PhysicalAddress[ 2 ]).ToString( "X" ) + ":" + ((uint)itf.PhysicalAddress[ 3 ]).ToString( "X" ) + ":" + ((uint)itf.PhysicalAddress[ 4 ]).ToString( "X" ) + ":" + ((uint)itf.PhysicalAddress[ 5 ]).ToString( "X" ) + );*/ return; } }while(StatusChanged.WaitOne()); }
/// <summary>Sleep wait for a network interface with a valid (e.g. not 0.0.0.0) IP address</summary> public void WaitForIpAddress( ) { do { StatusChanged.Reset( ); foreach (var itf in NetworkInterfaces) { if (itf.IPAddress == "0.0.0.0" || itf.IPAddress == "127.0.0.1") { continue; } Debug.Print("Found IP: " + itf.IPAddress); return; } } while(StatusChanged.WaitOne( )); }