/// <summary> /// 回收字符串缓存 /// </summary> /// <param name="_cache"></param> public static void Recover(StringListCacche _cache) { if (null != _cache) { _cache.Clear(); } CacheStack.Push(_cache); }
/// <summary> /// 获取一个限制字符串缓存器 /// </summary> /// <returns></returns> public static StringListCacche GetFree() { if (CacheStack.Count > 0) { StringListCacche cache = CacheStack.Pop(); return(cache); } return(new StringListCacche()); }
/// <summary> /// warring信息 /// 主要使用在参数检测部分 /// 不是特别重要的参数检测出异常,使用warring进行打印 /// 在生产环境中会被打印出来 /// </summary> /// <param name="_object"></param> /// <param name="_message"></param> public static void Warr(this object _object, StringListCacche _message) { if (null == _message) { return; } LogMessage(_object, LogLevels.Warning, _message.Release()); }
/// <summary> /// Error /// 错误信息,错误信息会在生产环境中打印出来 /// 在关键性信息加载错误时,会使用Error信息打印 /// </summary> public static void Error(this object _object, StringListCacche _errorMessage) { if (null == _errorMessage) { return; } _object.LogMessage(LogLevels.Error, _errorMessage.Release()); }
/// <summary> /// Reset /// </summary> public void Reset() { cacheBytes.Clear(); downloadSortSet.Clear(); if (null != errorInfoCache) { errorInfoCache.Release(); errorInfoCache = null; } UpdateInfo.Reset(); downloadQueueCompleteAction = null; downloadUpateInfoAction = null; }
/// <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(); }