Example #1
0
 private void OnInterfaceDetect(InterfaceDetectedEventArgs e)
 {
     if (InterfaceDetected != null)
     {
         InterfaceDetected(this, e);
     }
 }
Example #2
0
        private void StartBrowsing()
        {
            if (IsBrowsing)
            {
                return;
            }
            IsBrowsing = true;

            if (SynchronizationContext == null)
            {
                SynchronizationContext = SynchronizationContext.Current;
            }

            _interfaceHandlers = new Dictionary <int, NetworkInterfaceHandler>();

            NetworkInterfaceInformation[] interfaceInfos = NetworkInterfaceInformation.GetAllNetworkInterfaces();
            foreach (NetworkInterfaceInformation interfaceInfo in interfaceInfos)
            {
                if (interfaceInfo.NetworkInterfaceType == NetworkInterfaceType.Loopback)
                {
                    continue;
                }
                if (interfaceInfo.NetworkInterfaceType == NetworkInterfaceType.Tunnel)
                {
                    continue;
                }

                var networkInterface = new NetworkInterface(interfaceInfo);
                var e = new InterfaceDetectedEventArgs(networkInterface)
                {
                    Add = true
                };

                OnInterfaceDetect(e);
                if (e.Add)
                {
                    int index = interfaceInfo.GetIPProperties().GetIPv4Properties().Index;
                    _interfaceHandlers.Add(index, new NetworkInterfaceHandler(this, networkInterface));
                }
            }
            NetworkChange.NetworkAddressChanged += CheckNetworkInterfaceStatuses;
            CheckNetworkInterfaceStatuses(null, null);
        }
Example #3
0
        private void StartBrowsing()
        {
            if (IsBrowsing)
            {
                return;
            }
            IsBrowsing = true;

            if (SynchronizationContext == null)
            {
                SynchronizationContext = SynchronizationContext.Current;
            }

            _interfaceHandlers = new Dictionary<int, NetworkInterfaceHandler>();

            NetworkInterfaceInformation[] interfaceInfos = NetworkInterfaceInformation.GetAllNetworkInterfaces();
            foreach (NetworkInterfaceInformation interfaceInfo in interfaceInfos)
            {
                if (interfaceInfo.NetworkInterfaceType == NetworkInterfaceType.Loopback)
                {
                    continue;
                }
                if (interfaceInfo.NetworkInterfaceType == NetworkInterfaceType.Tunnel)
                {
                    continue;
                }

                var networkInterface = new NetworkInterface(interfaceInfo);
                var e = new InterfaceDetectedEventArgs(networkInterface)
                {
                    Add = true
                };

                OnInterfaceDetect(e);
                if (e.Add)
                {
                    int index = interfaceInfo.GetIPProperties().GetIPv4Properties().Index;
                    _interfaceHandlers.Add(index, new NetworkInterfaceHandler(this, networkInterface));
                }
            }
            NetworkChange.NetworkAddressChanged += CheckNetworkInterfaceStatuses;
            CheckNetworkInterfaceStatuses(null, null);
        }
Example #4
0
 private void OnInterfaceDetect(InterfaceDetectedEventArgs e)
 {
     if (InterfaceDetected != null)
     {
         InterfaceDetected(this, e);
     }
 }