private void OnDownloadAgentFailure(DownloadAgent sender, string errorMessage)
 {
     if (m_DownloadFailureEventHandler != null)
     {
         DownloadFailureEventArgs downloadFailureEventArgs = DownloadFailureEventArgs.Create(sender.Task.SerialId, sender.Task.DownloadPath, sender.Task.DownloadUri, errorMessage, sender.Task.UserData);
         m_DownloadFailureEventHandler(this, downloadFailureEventArgs);
         ReferencePool.Release(downloadFailureEventArgs);
     }
 }
 private void OnDownloadAgentSuccess(DownloadAgent sender, int lastDownloadedLength)
 {
     if (m_DownloadSuccessEventHandler != null)
     {
         DownloadSuccessEventArgs downloadSuccessEventArgs = DownloadSuccessEventArgs.Create(sender.Task.SerialId, sender.Task.DownloadPath, sender.Task.DownloadUri, sender.CurrentLength, sender.Task.UserData);
         m_DownloadSuccessEventHandler(this, downloadSuccessEventArgs);
         ReferencePool.Release(downloadSuccessEventArgs);
     }
 }
 private void OnDownloadAgentUpdate(DownloadAgent sender, int lastDownloadedLength)
 {
     m_DownloadCounter.RecordDownloadedLength(lastDownloadedLength);
     if (m_DownloadUpdateEventHandler != null)
     {
         DownloadUpdateEventArgs downloadUpdateEventArgs = DownloadUpdateEventArgs.Create(sender.Task.SerialId, sender.Task.DownloadPath, sender.Task.DownloadUri, sender.CurrentLength, sender.Task.UserData);
         m_DownloadUpdateEventHandler(this, downloadUpdateEventArgs);
         ReferencePool.Release(downloadUpdateEventArgs);
     }
 }
        /// <summary>
        /// 增加下载代理辅助器。
        /// </summary>
        /// <param name="downloadAgentHelper">要增加的下载代理辅助器。</param>
        public void AddDownloadAgentHelper(IDownloadAgentHelper downloadAgentHelper)
        {
            DownloadAgent agent = new DownloadAgent(downloadAgentHelper);

            agent.DownloadAgentStart   += OnDownloadAgentStart;
            agent.DownloadAgentUpdate  += OnDownloadAgentUpdate;
            agent.DownloadAgentSuccess += OnDownloadAgentSuccess;
            agent.DownloadAgentFailure += OnDownloadAgentFailure;

            m_TaskPool.AddAgent(agent);
        }