/// <summary> /// 开始下载 /// </summary> public void Start(string root, string localFileName, Action <HttpAsyDownload, long> nofity = null, Action <HttpAsyDownload> error = null) { lock (m_Lock) { this.Abort(); this.root = root; localName = localFileName; isDone = false; errorCode = ErrorCode.None; m_NotifyCallback = nofity; m_ErrorCallback = error; m_Content = new DownloadContent(fullName, false); length = 0; OnDownload(); } }
void OnFinish() { lock (m_Lock) { if (m_Content != null) { m_Content.Complete(); m_Content.Close(); m_Content = null; } if (m_Request != null) { m_Request.Abort(); m_Request = null; } isDone = true; } }
private void OnFailed(ErrorCode code) { lock (m_Lock) { if (m_Content != null) { m_Content.Failed(); m_Content.Close(); m_Content = null; } if (m_Request != null) { m_Request.Abort(); m_Request = null; } isDone = false; errorCode = code; m_ErrorCallback?.Invoke(this); } }