Ejemplo n.º 1
0
        /// <summary>
        /// 获取所有下载任务的信息。
        /// </summary>
        /// <returns>所有下载任务的信息。</returns>
        //public TaskInfo[] GetAllDownloadInfos()
        //{
        //    return m_TaskPool.GetAllTaskInfos();
        //}

        private void OnDownloadAgentStart(DownloadAgent sender)
        {
            if (m_DownloadStartEventHandler != null)
            {
                DownloadStartEventArgs downloadStartEventArgs = DownloadStartEventArgs.Create(sender.Task.SerialId, sender.Task.DownloadPath, sender.Task.DownloadUri, sender.CurrentLength, sender.Task.UserData);
                m_DownloadStartEventHandler(this, downloadStartEventArgs);
                ReferencePool.Release(downloadStartEventArgs);
            }
        }
        /// <summary>
        /// 创建下载开始事件。
        /// </summary>
        /// <param name="serialId">下载任务的序列编号。</param>
        /// <param name="downloadPath">下载后存放路径。</param>
        /// <param name="downloadUri">下载地址。</param>
        /// <param name="currentLength">当前大小。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <returns>创建的下载开始事件。</returns>
        public static DownloadStartEventArgs Create(int serialId, string downloadPath, string downloadUri, int currentLength, object userData)
        {
            DownloadStartEventArgs downloadStartEventArgs = ReferencePool.Acquire <DownloadStartEventArgs>();

            downloadStartEventArgs.SerialId      = serialId;
            downloadStartEventArgs.DownloadPath  = downloadPath;
            downloadStartEventArgs.DownloadUri   = downloadUri;
            downloadStartEventArgs.CurrentLength = currentLength;
            downloadStartEventArgs.UserData      = userData;
            return(downloadStartEventArgs);
        }