private void onChannelClosed(object sender, EventArgs e) { UdpInputChannel channel = (UdpInputChannel)sender; lock (_CurrentChannelLockObject) { if (_CurrentChannel == channel) { _CurrentChannel = null; } } }
private bool createOrRetrieveChannel(out UdpInputChannel channel) { bool createChannel = false; channel = _CurrentChannel; if (channel == null) { lock (_CurrentChannelLockObject) { channel = _CurrentChannel; if (channel == null) { channel = new UdpInputChannel(this); channel.Closed += onChannelClosed; _CurrentChannel = channel; createChannel = true; } } } return(createChannel); }