/// <summary> /// Register a throttle with this throttling container /// </summary> public void RegisterThrottle(Throttle throttle) { if (throttle == null) { throw new NFXException(StringConsts.ARGUMENT_ERROR + "RegisterThrottle(NULL)"); } lock (m_Throttles) { if (!m_Throttles.TryAdd(throttle.Name, throttle)) { throw new NFXException(StringConsts.ARGUMENT_ERROR + throttle.Name + " throttle already exists"); } throttle.__setThrottling(this); } }
/// <summary> /// Unregister a throttle from this throttling container /// </summary> /// <returns>True if throttle was successfully unregistered</returns> public bool UnregisterThrottle(Throttle throttle) { if (throttle == null) { throw new NFXException(StringConsts.ARGUMENT_ERROR + "UnregisterThrottle(NULL)"); } Throttle value; lock (m_Throttles) { bool ok = m_Throttles.TryRemove(throttle.Name, out value); if (ok) { throttle.__setThrottling(null); } return(ok); } }