/// <exception cref="Exception">When called concurrently with <see cref="TickAsync"/>.</exception> public bool TryRemove(IPlace place) { if (_tickTask != null && !_tickTask.IsCompleted) { throw new Exception($"{nameof(TryRemove)} called during tick."); } if (!place.IsEmpty) { throw new InvalidOperationException( $"Calling {nameof(TryRemove)} on non-empty {nameof(Place)} is not allowed." ); } var removed = _places.TryRemove(place, out _); if (removed) { place.Dispose(); } // Todo: this can/should(?) be optimized by caching ITransition references in Places foreach (var transition in _transitions) { transition.Key.RemoveAllArcs(place); } return(removed); }