private void OnDownloadAgentStart(DownloadAgent sender) { if (m_DownloadStartEventHandler != null) { m_DownloadStartEventHandler(this, new DownloadStartEventArgs(sender.Task.SerialId, sender.Task.DownloadPath, sender.Task.DownloadUri, sender.CurrentLength, sender.Task.UserData)); } }
private void OnDownloadAgentFailure(DownloadAgent sender, string errorMessage) { if (m_DownloadFailureEventHandler != null) { m_DownloadFailureEventHandler(this, new DownloadFailureEventArgs(sender.Task.SerialId, sender.Task.DownloadPath, sender.Task.DownloadUri, errorMessage, sender.Task.UserData)); } }
private void OnDownloadAgentSuccess(DownloadAgent sender, int lastDownloadedLength) { m_DownloadCounter.RecordDownloadedLength(lastDownloadedLength); if (m_DownloadSuccessEventHandler != null) { m_DownloadSuccessEventHandler(this, new DownloadSuccessEventArgs(sender.Task.SerialId, sender.Task.DownloadPath, sender.Task.DownloadUri, sender.CurrentLength, sender.Task.UserData)); } }
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); }