BitSharper.PeerGroup.Run C# (CSharp) 메소드

Run() 공개 메소드

Repeatedly get the next peer address from the inactive queue and try to connect.
We can be terminated with Thread.interrupt. When an interrupt is received, we will ask the executor to shutdown and ask each peer to disconnect. At that point no threads or network connections will be active.
public Run ( ) : void
리턴 void
        public void Run()
        {
            try
            {
                while (_running)
                {
                    if (_inactives.Count == 0)
                    {
                        DiscoverPeers();
                    }
                    else
                    {
                        TryNextPeer();
                    }

                    // We started a new peer connection, delay before trying another one
                    Thread.Sleep(_connectionDelayMillis);
                }
            }
            catch (ThreadInterruptedException)
            {
                lock (this)
                {
                    _running = false;
                }
            }
            _peerPool.ShutdownNow();
            lock (_peers)
            {
                foreach (var peer in _peers)
                {
                    peer.Disconnect();
                }
            }
        }