Reachability.Reachability.RemoteHostStatus C# (CSharp) Метод

RemoteHostStatus() публичный статический Метод

public static RemoteHostStatus ( ) : NetworkStatus
Результат NetworkStatus
		public static NetworkStatus RemoteHostStatus ()
		{
			NetworkReachabilityFlags flags;
			bool reachable;

			if (remoteHostReachability == null) {
				remoteHostReachability = new NetworkReachability (HostName);

				// Need to probe before we queue, or we wont get any meaningful values
				// this only happens when you create NetworkReachability from a hostname
				reachable = remoteHostReachability.TryGetFlags (out flags);

				remoteHostReachability.SetNotification (OnChange);
				remoteHostReachability.Schedule (CFRunLoop.Current, CFRunLoop.ModeDefault);
			} else {
				reachable = remoteHostReachability.TryGetFlags (out flags);
			}

			if (!reachable)
				return NetworkStatus.NotReachable;

			if (!IsReachableWithoutRequiringConnection (flags))
				return NetworkStatus.NotReachable;

			return (flags & NetworkReachabilityFlags.IsWWAN) != 0 ?
				NetworkStatus.ReachableViaCarrierDataNetwork : NetworkStatus.ReachableViaWiFiNetwork;
		}

Usage Example

Пример #1
0
 void UpdateStatus(object sender, EventArgs e)
 {
     remoteHostStatus = Reachability.RemoteHostStatus();
     internetStatus   = Reachability.InternetConnectionStatus();
     localWifiStatus  = Reachability.LocalWifiConnectionStatus();
     TableView.ReloadData();
 }