/// <summary>
        /// 注册下载段
        /// </summary>
        /// <param name="downloadSegment"></param>
        public void RegisterDownloadSegment(DownloadSegment downloadSegment)
        {
            downloadSegment.Message = "Start RegisterDownloadSegment";
            lock (_locker)
            {
                // 找到顺序
                var n = DownloadSegmentList.FindIndex(temp => temp.StartPoint > downloadSegment.StartPoint);
                if (n < 0)
                {
                    // 找不到一个比他大的,放在最后面
                    DownloadSegmentList.Add(downloadSegment);
                }
                else
                {
                    // 原本是按照顺序的,找到第一个比他大的,放在前面
                    DownloadSegmentList.Insert(n, downloadSegment);
                }

                downloadSegment.Number = DownloadSegmentList.Count;

                downloadSegment.SegmentManager = this;
            }

            downloadSegment.Message = "Finish RegisterDownloadSegment";
        }
Beispiel #2
0
        public void RegisterDownloadSegment(DownloadSegment downloadSegment)
        {
            lock (_locker)
            {
                // 找到顺序
                var n = DownloadSegmentList.FindIndex(temp => temp.StartPoint > downloadSegment.StartPoint);
                if (n < 0)
                {
                    DownloadSegmentList.Add(downloadSegment);
                }
                else
                {
                    DownloadSegmentList.Insert(n, downloadSegment);
                }

                downloadSegment.Number = DownloadSegmentList.Count;

                downloadSegment.SegmentManager = this;
            }
        }