NetworkInterfaceType Property
Collapse the table of content
Expand the table of content

NetworkInterface.NetworkInterfaceType Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the type of the network that is servicing Internet requests.

Namespace:  Microsoft.Phone.Net.NetworkInformation
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)

'Declaration
Public Shared ReadOnly Property NetworkInterfaceType As NetworkInterfaceType

Currently, the only values that will be returned are the following:

  • Wireless80211

  • Ethernet

  • MobileBroadbandGSM

  • MobileBroadbandCDMA

  • None


       private event EventHandler NetworkInterfaceTypeChanged;

        private bool _networkTypeLoaded;

        private NetworkInterfaceType _currentNetworkType;        

        public void PlayVideo(string videoId)
        {
            if (_networkTypeLoaded == false)
            {
                
                // The network type has not yet been determined, so
                // show a loading screen and register for an event
                // when the network type is known.
                ShowLoadingScreen();
                NetworkInterfaceTypeChanged +=
                    delegate
                    {
                        DismissLoadingScreen();
                        PlayVideo(videoId);
                    };

                CheckCurrentNetworkType();
                return;
            }            
                
            switch(_currentNetworkType)
            {
               
                // If the device is connected to a cellular network,
                // then play a low-resolution video.
                case NetworkInterfaceType.MobileBroadbandCdma:
                case NetworkInterfaceType.MobileBroadbandGsm:
                    PlayLowResVideo(videoId);
                    break;


                // If the device is connected by Wi-Fi or connected to the desktop, 
                // then play higher-resolution video.
                case NetworkInterfaceType.Wireless80211:
                case NetworkInterfaceType.Ethernet:
                    PlayHighResVideo(videoId);
                    break;

                // If no network connection is available,
                // then display an error message.
                case NetworkInterfaceType.None:
                default:
                    DisplayNetworkUnavailableErrorMessage();
                    break;

            }          
        }

        private void CheckCurrentNetworkType()
        {
           
            // Checking the network type is not instantaneous,
            // so we recommend that you always do it on a background thread.
            ThreadPool.QueueUserWorkItem((o) =>
            {
                _currentNetworkType = Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType;
                _networkTypeLoaded = true;

                if (NetworkInterfaceTypeChanged != null)
                {
                     NetworkInterfaceTypeChanged(this, EventArgs.Empty);
                }
            });
        }


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft