void ClearClient() { _client.DownloadProgressChanged -= OnDownloadProgressChanged; _client.DownloadFileCompleted -= OnDownloadFileCompleted; _client.Dispose(); _client = null; }
/// <summary> /// 销毁对象,会停止所有的下载 /// </summary> public void Dispose() { if (_client != null) { _client.DownloadProgressChanged -= OnDownloadProgressChanged; _client.DownloadFileCompleted -= OnDownloadFileCompleted; _client.CancelAsync(); _client.Dispose(); _client = null; if (false == _isDone) { SetError("Canceled"); _isDone = true; } } }