private void OnDownloadAgentHelperComplete(object sender, DownloadAgentHelperCompleteEventArgs e) { m_WaitTime = 0f; m_DownloadedLength = e.Length; if (m_SavedLength != CurrentLength) { throw new Exception("Internal download error."); } m_Helper.Reset(); m_FileStream.Close(); m_FileStream = null; if (File.Exists(m_Task.DownloadPath)) { File.Delete(m_Task.DownloadPath); } File.Move(Utility.Text.Format("{0}.download", m_Task.DownloadPath), m_Task.DownloadPath); m_Task.Status = DownloadTaskStatus.Done; if (DownloadAgentSuccess != null) { DownloadAgentSuccess(this, e.Length); } m_Task.Done = true; }
/// <summary> /// 创建下载代理辅助器完成事件。 /// </summary> /// <param name="length">下载的数据大小。</param> /// <returns>创建的下载代理辅助器完成事件。</returns> public static DownloadAgentHelperCompleteEventArgs Create(int length) { if (length < 0) { throw new Exception("Length is invalid."); } DownloadAgentHelperCompleteEventArgs downloadAgentHelperCompleteEventArgs = ReferencePool.Acquire <DownloadAgentHelperCompleteEventArgs>(); downloadAgentHelperCompleteEventArgs.Length = length; return(downloadAgentHelperCompleteEventArgs); }