public StatusCode SetNotification(Notification callback)
        {
            if (notification == null)
            {
                if (callback == null)
                {
                    return(StatusCode.OK);
                }

                gch = GCHandle.Alloc(this);
                var ctx = new SCNetworkReachabilityContext(GCHandle.ToIntPtr(gch));

                lock (typeof(NetworkReachability)){
                    if (callouth == null)
                    {
                        callouth = Callback;
                    }
                }

                if (!SCNetworkReachabilitySetCallback(handle, callouth, ref ctx))
                {
                    return(StatusCodeError.SCError());
                }
            }
            else
            {
                if (callback == null)
                {
                    this.notification = null;
                    callouth          = null;
                    if (!SCNetworkReachabilitySetCallback(handle, null, IntPtr.Zero))
                    {
                        return(StatusCodeError.SCError());
                    }

                    return(StatusCode.OK);
                }
            }

            this.notification = callback;
            return(StatusCode.OK);
        }
Exemple #2
0
		public StatusCode SetNotification (Notification callback)
		{
			if (notification == null){
				if (callback == null)
					return StatusCode.OK;
			
				gch = GCHandle.Alloc (this);
				var ctx = new SCNetworkReachabilityContext (GCHandle.ToIntPtr (gch));

				lock (typeof (NetworkReachability)){
					if (callouth == null)
						callouth = Callback;
				}
				
				if (!SCNetworkReachabilitySetCallback (handle, callouth, ref ctx))
					return StatusCodeError.SCError ();
			} else {
				if (callback == null){
					this.notification = null;
					callouth = null;
					if (!SCNetworkReachabilitySetCallback (handle, null, IntPtr.Zero))
						return StatusCodeError.SCError ();
					
					return StatusCode.OK;
				}
			}
			
			this.notification = callback;
			return StatusCode.OK;
		}
 static extern /* Boolean */ bool SCNetworkReachabilitySetCallback(
     /* SCNetworkReachabilityRef __nullable */ IntPtr handle,
     /* __nullable */ SCNetworkReachabilityCallBack callout,
     /* SCNetworkReachabilityContext* __nullable */ IntPtr context);
Exemple #4
0
		static extern /* Boolean */ bool SCNetworkReachabilitySetCallback (
			/* SCNetworkReachabilityRef __nullable */ IntPtr handle, 
			/* __nullable */ SCNetworkReachabilityCallBack callout, 
			/* SCNetworkReachabilityContext* __nullable */ IntPtr context);