public void OnDownloadFile(ref DownloadInfo downloadInfo) { if (downloadInfo != null) { try { if (DownloadUpdateHistory.Instance.ExistDownloadHistory(downloadInfo.local_asset_path)) { this.CancelDownload(); } else { this.m_normal_download_state = true; this.m_current_res = downloadInfo.server_asset_path; this.m_pro_event_proxy.downloadInfo = downloadInfo; if (this.m_client == null || this.m_client.IsBusy) { if (this.m_client != null) { this.m_client.Dispose(); } this.m_client = new WebClient(); this.m_client.DownloadFileCompleted += this.m_pro_event_proxy.DownloadFileCompleted; this.m_client.DownloadProgressChanged += this.m_pro_event_proxy.OnProgrssChanged; } string save_file = downloadInfo.local_asset_path; this.m_client.DownloadFileAsync(new Uri(this.m_current_res), save_file); } } catch (Exception e) { this.CancelDownload(); string file_name = Util.GetAssetsBundlePathFromBase64(downloadInfo.server_asset_path); Util.ThrowLuaException(string.Concat(new string[] { "auto download res error, file name:", downloadInfo.server_asset_path, " error:", e.Message, " raw file:", file_name }), null, 1); } } }
public void AddEvent(DownloadInfo ev) { Queue <DownloadInfo> normal_list = m_normal_list; lock (normal_list) { if (m_normal_list.Count == 0) { this.m_start_download_time = Time.time; } m_normal_list.Enqueue(ev); } if (!this.m_init_thread) { this.m_pro_event_proxy = new ProgressEventProxy(); this.m_pro_event_proxy.progressMethod = new Action <DownloadInfo, DownloadProgressChangedEventArgs>(this.ProgressChanged); this.m_pro_event_proxy.completeMethod = new Action <DownloadInfo, AsyncCompletedEventArgs>(this.DownloadFileCompleted); this.m_normal_thread = new Thread(new ThreadStart(this.OnUpdateNormal)); this.m_normal_thread.Priority = System.Threading.ThreadPriority.BelowNormal; this.m_normal_thread.Start(); this.m_init_thread = true; } }
public NotiData(DownloadInfo param) { this.evParam = param; }