コード例 #1
0
        static async Task <CustomPiecePicker> ChangeTorrentManagerPicker(TorrentManager torrentManager)
        {
            var picker = new CustomPiecePicker(new StandardPicker());
            await torrentManager.ChangePickerAsync(picker);

            return(picker);
        }
コード例 #2
0
        public BtsTorrentManager(TorrentManager monoTorrentManager, BtsTorrent torrent, CustomPiecePicker customPiecePicker)
        {
            MonoTorrentManager = monoTorrentManager;
            Torrent            = torrent;

            var piecesCount = torrent.MonoTorrent.Pieces.Count;

            _customPiecePicker = customPiecePicker;
            _pieceRequests     = new BtsPieceRequest[piecesCount];

            MonoTorrentManager.PieceHashed += (_, args) =>
            {
                if (!args.HashPassed)
                {
                    return;
                }
                var piece = args.PieceIndex;
                lock (_lock)
                {
                    _pieceRequests[piece]?.Complete();
                }
            };
        }