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); }
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);
static extern /* Boolean */ bool SCNetworkReachabilitySetCallback ( /* SCNetworkReachabilityRef __nullable */ IntPtr handle, /* __nullable */ SCNetworkReachabilityCallBack callout, /* SCNetworkReachabilityContext* __nullable */ IntPtr context);