/// <inheritdoc /> public void Connect(ISocketPollable endpoint) { if (DispatchedSockets.Contains(endpoint) == false) { SyncLock.Wait(); try { if (DispatchedSockets.Contains(endpoint) == false) { DispatchedSockets.Add(endpoint); if (PollingThread?.IsValueCreated == true) { PollingThread.Value.Add(endpoint); } } } finally { SyncLock.Release(); } } }
/// <inheritdoc /> public void Dispose() { SyncLock.Wait(); try { if (PollingThread?.IsValueCreated == true) { foreach (var socket in DispatchedSockets) { PollingThread.Value.Remove(socket); } DispatchedSockets.Clear(); PollingThread.Value.Dispose(); } } finally { SyncLock.Release(); } GC.SuppressFinalize(this); }