3 using Microsoft.Win32.SafeHandles;
5 namespace System.Net.NetworkInformation
7 // This class guarantees that any in-progress notifications will be canceled before the AppDomain gets unloaded.
8 // CancelMibChangeNotify2 guarantees that after it returns, the callback will NEVER be called. It may block
9 // for a small amount of time if the callback is currently in progress, which is fine (and, intentional).
11 [SuppressUnmanagedCodeSecurity]
12 internal class SafeCancelMibChangeNotify : SafeHandleZeroOrMinusOneIsInvalid
14 public SafeCancelMibChangeNotify() : base(true) { }
16 protected override bool ReleaseHandle()
18 uint err = UnsafeNetInfoNativeMethods.CancelMibChangeNotify2(base.handle);
19 base.handle = IntPtr.Zero;
20 return (err == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS);