void Instance_DownloadRemoved(object sender, DownloaderEventArgs e) { this.Dispatcher.BeginInvoke(new Action(() => { DownLoadFileInfo item = mapDownloadToObj[e.Downloader] as DownLoadFileInfo; if (item != null) { DownloadingList.Remove(item); mapDownloadToObj[e.Downloader] = null; mapObjToDownload[item] = null; } } )); }
/// <summary> /// /// </summary> void _DownloadError(HttpAsyDownload d) { lock (lock_obj_) { //加入失败列表 string file_name = d.LocalName; bool is_compress = Compress.IsCompressFile(file_name); string assetbundlename = is_compress ? Compress.GetDefaultFileName(file_name) : file_name; FailedDownloadList.Add(assetbundlename); DownloadingList.Remove(assetbundlename); if (d.ErrorCode == HttpAsyDownload.emErrorCode.DiskFull) { Error(emErrorCode.DiskFull, assetbundlename); } else { Error(emErrorCode.DownloadFailed, assetbundlename); } } }
/// <summary> /// 下载完成 /// </summary> void DownloadSucceed(string file_name) { lock (lock_obj_) { bool is_compress = Compress.IsCompressFile(file_name); string assetbundlename = is_compress ? Compress.GetDefaultFileName(file_name) : file_name; CompleteDownloadList.Add(assetbundlename); DownloadingList.Remove(assetbundlename); //判断是否需要解压文件 if (is_compress) { // 解压文件 string in_file = Root + "/" + file_name; string out_file = Root + "/" + assetbundlename; Compress.DecompressFile(in_file, out_file); // 删除压缩包 System.IO.File.Delete(in_file); } } }