/// <summary> /// add new task. the status of the new task will be "Paused" /// if task with the same md5 exists, remove it before add new task /// </summary> /// <param name="md5"></param> /// <param name="url"></param> /// <returns></returns> public DownloadTaskInfo AddTask(String md5, String url) { lock (m_lock) { { Task existTask; if (m_taskMap.TryGetValue(md5, out existTask)) return existTask.ToDownloadTaskInfo(); } Task task = new Task(); task.md5 = md5; task.url = url; task.localPath = Path.Combine(m_rootDir, md5); task.status = DownloadTaskStatus.Paused; task.totalSize = 0; //unknown task.finishedSize = 0; task.errorCode = DownloadTaskErrorCode.Success; m_taskMap.Add(md5, task); return task.ToDownloadTaskInfo(); } }