public virtual bool Remove(Lifecycle instance) { lock (this) { for (int i = 0; i < _instances.Count; i++) { if (_instances[i].isInstance(instance)) { IList <LifecycleInstance> tmp = new List <LifecycleInstance>(_instances); LifecycleInstance lifecycleInstance = tmp.RemoveAt(i); lifecycleInstance.Shutdown(); _instances = tmp; return(true); } } return(false); } }
/// <summary> /// Shutdown all registered instances, transitioning from either STARTED or STOPPED to SHUTDOWN. /// <para> /// If any instance fails to shutdown, the rest of the instances will still be shut down, /// so that the overall status is SHUTDOWN. /// </para> /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public synchronized void shutdown() throws LifecycleException public override void Shutdown() { lock (this) { LifecycleException ex = null; try { Stop(); } catch (LifecycleException e) { ex = e; } if (_status == LifecycleStatus.Stopped) { _status = ChangedStatus(this, _status, LifecycleStatus.ShuttingDown); for (int i = _instances.Count - 1; i >= 0; i--) { LifecycleInstance lifecycleInstance = _instances[i]; try { lifecycleInstance.Shutdown(); } catch (LifecycleException e) { ex = Exceptions.chain(ex, e); } } _status = ChangedStatus(this, _status, LifecycleStatus.Shutdown); if (ex != null) { throw ex; } } } }