private void DoScan(object sender, ElapsedEventArgs e) { GetChannellockObj.EnterUpgradeableReadLock(); try { var keysToRemove = new List <ChannelWrapper>(); foreach (var item in ChannelList) { if (!item.IsBusy && (!item.Reusable || item.IdleTime.GetDurationSeconds(DateTime.UtcNow) >= MaxIdleTime)) { keysToRemove.Add(item); } } foreach (var item in keysToRemove) { GetChannellockObj.EnterWriteLock(); try { ChannelList.Remove(item); item.Dispose(); } finally { GetChannellockObj.ExitWriteLock(); } } } finally { GetChannellockObj.ExitUpgradeableReadLock(); } }
private void OnUnsubscribe(Messages.ChannelUnsubscribing data) { try { lock (channelLocker) { ChannelList.Remove(data.ChannelId); } } catch (Exception e) { Log.Error(e); throw; } }
public void RemoveChannel(Channel channel) { Debug.Assert(CheckChannel(channel)); ChannelList.Remove(channel); }