Beispiel #1
0
        void CancelWhere(Predicate <Block> predicate)
        {
            bool cancelled = false;

            requests.ForEach(delegate(Piece p) {
                for (int i = 0; i < p.Blocks.Length; i++)
                {
                    if (predicate(p.Blocks[i]) && !p.Blocks[i].Received)
                    {
                        cancelled = true;
                        p.Blocks[i].CancelRequest();
                    }
                }
            });

            if (cancelled)
            {
                requests.RemoveAll(delegate(Piece p) { return(p.NoBlocksRequested); });
            }
        }
Beispiel #2
0
        void CancelWhere(Predicate <Block> predicate)
        {
            bool cancelled = false;

            for (int p = 0; p < requests.Count; p++)
            {
                var blocks = requests [p].Blocks;
                for (int i = 0; i < blocks.Length; i++)
                {
                    if (predicate(blocks[i]) && !blocks[i].Received)
                    {
                        cancelled = true;
                        blocks[i].CancelRequest();
                    }
                }
            }

            if (cancelled)
            {
                requests.RemoveAll(delegate(Piece p) { return(p.NoBlocksRequested); });
            }
        }