Ejemplo n.º 1
0
        /// <summary>
        /// </summary>
        public void DetachFromPoller()
        {
            if (this.m_attachedPoller == null)
            {
                throw new InvalidOperationException("Not attached to a poller");
            }

            this.m_attachedPoller.Remove(this.m_monitoringSocket);
            this.m_attachedPoller = null;
            this.InternalClose();
        }
        public void AttachToPoller(ISocketPollableCollection poller)
        {
            if (poller == null)
            {
                throw new ArgumentNullException("poller");
            }
            if (IsRunning)
            {
                throw new InvalidOperationException("Monitor already started");
            }
            if (Interlocked.CompareExchange(ref m_attachedPoller, poller, null) != null)
            {
                throw new InvalidOperationException("Already attached to a poller");
            }

            InternalStart();
            poller.Add(m_monitoringSocket);
        }
Ejemplo n.º 3
0
        private void DetachFromPoller(bool dispose)
        {
            if (m_attachedPoller == null)
            {
                throw new InvalidOperationException("Not attached to a poller");
            }

            if (dispose)
            {
                m_attachedPoller.RemoveAndDispose(m_monitoringSocket);
            }
            else
            {
                m_attachedPoller.Remove(m_monitoringSocket);
            }
            m_attachedPoller = null;
            InternalClose();
        }