Esempio n. 1
0
        /// <summary>
        /// 重置写入流
        /// </summary>
        private void ResetWriter()
        {
            if (null == writerStream)
            {
                writerStream = new MemoryStream();
            }
            else
            {
                writerStream.SetLength(0);
            }

            if (null == binaryWrite)
            {
                binaryWrite = new BinaryWriter(writerStream);
            }

            logIndex = 0;
            LogCache.SetSplit("\n");
        }
Esempio n. 2
0
        /// <summary>
        /// 资源下载失败的处理
        /// 要向资源错误原因中添加一条错误记录
        /// </summary>
        /// <param name="_item"></param>
        /// <param name="_errorCode"></param>
        private void DownloadFailExecute(HKDownloadTaskItem _item, int _errorCode)
        {
            if (null == errorInfoCache)
            {
                errorInfoCache = StringCacheFactory.GetFree();
                errorInfoCache.SetSplit("\n");
            }

            if (_item.CurrentSurplusRetryCount > 0)
            {
                RetryExecute(_item);
                errorInfoCache.Add(_item.Url).Add(" 下载失败,启动第").Add(_item.RetryCount - _item.CurrentSurplusRetryCount)
                .Add("次重试");
            }
            else
            {
                errorInfoCache.Add(_item.Url).Add(" 下载失败 = ").Add("_").Add(_errorCode);
                // 使用完后,就回收到内存池中
                HKDownloadTaskItem.downloadItemCache.Recover(_item);
            }

            // 检测当前剩余下载对象,并继续下载
            CheckQueueComplete();
        }