Esempio n. 1
0
        private static void OnSocketEvent(Interop.Sys.NetworkChangeKind kind)
        {
            switch (kind)
            {
            case Interop.Sys.NetworkChangeKind.AddressAdded:
            case Interop.Sys.NetworkChangeKind.AddressRemoved:
                s_addressChangedSubscribers?.Invoke(null, EventArgs.Empty);
                break;

            case Interop.Sys.NetworkChangeKind.AvailabilityChanged:
                lock (s_availabilityLock)
                {
                    if (!s_availabilityHasChanged)
                    {
                        s_availabilityTimer.Change(AvailabilityTimerWindowMilliseconds, -1);
                    }

                    s_availabilityHasChanged = true;
                }
                break;
            }
        }
 private static void OnAddressChanged(IntPtr store, IntPtr changedKeys, IntPtr info)
 {
     s_addressChangedSubscribers?.Invoke(null, EventArgs.Empty);
     s_availabilityChangedSubscribers?.Invoke(null, new NetworkAvailabilityEventArgs(NetworkInterface.GetIsNetworkAvailable()));
 }