Ejemplo n.º 1
0
        /// <summary>
        ///     Removes a connection from the currently active ones
        /// </summary>
        /// <param name="obj">The connectable to remove</param>
        public void DeleteConnectable(IConnectable obj)
        {
            obj.Disable();
            lock (_tickLock)
            {
                if (!Nodes.Contains(obj))
                {
                    return;
                }

                var mdata = _connectableMetadata[obj];

                // Remove the node from all connections
                foreach (var node in Nodes)
                {
                    DisconnectConnectables(obj, node);
                    DisconnectConnectables(node, obj);
                }

                // Unregister the node and metadata
                Nodes.Remove(obj);
                obj.Id = -1;
                _connectableMetadata.Remove(obj);

                // Check to see if the connection has a ticker
                var dc = obj as DataConnection;
                if (dc != null && dc.Poller != null && dc.Poller.IsTickPoller)
                {
                    _tickers.Remove(dc.Poller);
                    if (_tickers.Count <= 0)
                    {
                        _tickTimer.Change(Timeout.Infinite, Timeout.Infinite);
                    }
                }

                OnBlockDeleted?.Invoke(this, obj);
            }
        }