private static void ProcessEvent(int socket, Interop.Sys.NetworkChangeKind kind) { if (kind != Interop.Sys.NetworkChangeKind.None) { lock (s_gate) { if (socket == s_socket) { OnSocketEvent(kind); } } } }
private static void OnSocketEvent(Interop.Sys.NetworkChangeKind kind) { switch (kind) { case Interop.Sys.NetworkChangeKind.AddressAdded: case Interop.Sys.NetworkChangeKind.AddressRemoved: NetworkAddressChangedEventHandler handler = s_addressChangedSubscribers; if (handler != null) { handler(null, EventArgs.Empty); } break; } }
private static void LoopReadSocket(int socket) { while (socket == s_socket) { Interop.Sys.NetworkChangeKind kind = Interop.Sys.ReadSingleEvent(socket); if (kind == Interop.Sys.NetworkChangeKind.None) { continue; } else { lock (s_lockObj) { if (socket == s_socket) { OnSocketEvent(kind); } } } } }
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 OnSocketEvent(Interop.Sys.NetworkChangeKind kind) { switch (kind) { case Interop.Sys.NetworkChangeKind.AddressAdded: case Interop.Sys.NetworkChangeKind.AddressRemoved: OnAddressChanged(); break; case Interop.Sys.NetworkChangeKind.AvailabilityChanged: lock (s_gate) { if (s_availabilityTimer != null) { if (!s_availabilityHasChanged) { s_availabilityTimer.Change(AvailabilityTimerWindowMilliseconds, -1); } s_availabilityHasChanged = true; } } break; } }