コード例 #1
0
        public void Stop()
        {
            Log.WriteLine("stopping client");

            _isStopping = true;
            DisablePeerConnections();
            Torrent.UpdateTrackers(TrackerEvent.Stopped, Id, Port);
        }
コード例 #2
0
        public void Start()
        {
            Log.WriteLine("starting client");

            _isStopping = false;

            Torrent.ResetTrackersLastRequest();

            EnablePeerConnections();

            // tracker thread
            new Thread(() =>
            {
                while (!_isStopping)
                {
                    Torrent.UpdateTrackers(TrackerEvent.Started, Id, Port);
                    Thread.Sleep(10000);
                }
            }).Start();

            // peer thread
            new Thread(() =>
            {
                while (!_isStopping)
                {
                    ProcessPeers();
                    Thread.Sleep(1000);
                }
            }).Start();

            // upload thread
            new Thread(() =>
            {
                while (!_isStopping)
                {
                    ProcessUploads();
                    Thread.Sleep(1000);
                }
            }).Start();

            // download thread
            new Thread(() =>
            {
                while (!_isStopping)
                {
                    ProcessDownloads();
                    Thread.Sleep(1000);
                }
            }).Start();
        }