Example #1
0
        public void Dispose()
        {
            lock (this) {
                if (handle == IntPtr.Zero)
                {
                    return;
                }

                if (scheduledWithRunLoop)
                {
                    SCNetworkReachabilityUnscheduleFromRunLoop(handle, CFRunLoopGetMain(), runLoopMode);
                }

                CFRelease(handle);
                handle               = IntPtr.Zero;
                callback             = null;
                flags                = NetworkReachabilityFlags.None;
                scheduledWithRunLoop = false;
            }
        }
Example #2
0
        public MacNetworkChange()
        {
            var sockaddr = sockaddr_in.Create();

            handle = SCNetworkReachabilityCreateWithAddress(IntPtr.Zero, ref sockaddr);
            if (handle == IntPtr.Zero)
            {
                throw new Exception("SCNetworkReachabilityCreateWithAddress returned NULL");
            }

            callback = new SCNetworkReachabilityCallback(HandleCallback);
            var info = new SCNetworkReachabilityContext {
                info = GCHandle.ToIntPtr(GCHandle.Alloc(this))
            };

            SCNetworkReachabilitySetCallback(handle, callback, ref info);

            scheduledWithRunLoop =
                LoadRunLoopMode() &&
                SCNetworkReachabilityScheduleWithRunLoop(handle, CFRunLoopGetMain(), runLoopMode);

            SCNetworkReachabilityGetFlags(handle, out flags);
        }
Example #3
0
 static extern bool SCNetworkReachabilitySetCallback(IntPtr reachability, SCNetworkReachabilityCallback callback, ref SCNetworkReachabilityContext context);
Example #4
0
		public void Dispose ()
		{
			lock (this) {
				if (handle == IntPtr.Zero)
					return;

				if (scheduledWithRunLoop)
					SCNetworkReachabilityUnscheduleFromRunLoop (handle, CFRunLoopGetMain (), runLoopMode);

				CFRelease (handle);
				handle = IntPtr.Zero;
				callback = null;
				flags = NetworkReachabilityFlags.None;
				scheduledWithRunLoop = false;
			}
		}
Example #5
0
		public MacNetworkChange ()
		{
			var sockaddr = sockaddr_in.Create ();
			handle = SCNetworkReachabilityCreateWithAddress (IntPtr.Zero, ref sockaddr);
			if (handle == IntPtr.Zero)
				throw new Exception ("SCNetworkReachabilityCreateWithAddress returned NULL");

			callback = new SCNetworkReachabilityCallback (HandleCallback);
			var info = new SCNetworkReachabilityContext {
				info = GCHandle.ToIntPtr (GCHandle.Alloc (this))
			};

			SCNetworkReachabilitySetCallback (handle, callback, ref info);

			scheduledWithRunLoop =
			LoadRunLoopMode () &&
				SCNetworkReachabilityScheduleWithRunLoop (handle, CFRunLoopGetMain (), runLoopMode);

			SCNetworkReachabilityGetFlags (handle, out flags);
		}
Example #6
0
		static extern bool SCNetworkReachabilitySetCallback (IntPtr reachability, SCNetworkReachabilityCallback callback, ref SCNetworkReachabilityContext context);