void OnChannelClosed(object sender, EventArgs args) { CustomHttpInputChannel channel = (CustomHttpInputChannel)sender; lock (this.currentChannelLock) { if (channel == this.currentChannel) { this.currentChannel = null; } } }
bool CreateOrRetrieveChannel(out CustomHttpInputChannel newChannel) { bool channelCreated = false; if ((newChannel = currentChannel) == null) { lock (currentChannelLock) { if ((newChannel = currentChannel) == null) { newChannel = new CustomHttpInputChannel(this); newChannel.Closed += new EventHandler(this.OnChannelClosed); currentChannel = newChannel; channelCreated = true; } } } return(channelCreated); }