From b79fb5e9a9354b48bb3ea9e52e816c79913d4087 Mon Sep 17 00:00:00 2001 From: shawnnqin Date: Thu, 17 Nov 2022 10:54:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmono=20runtime=E4=B8=8B?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E9=AB=98=E7=BA=A7=E4=B8=8B=E8=BD=BD=20Pause?= =?UTF-8?q?=20&=20Resume=20=E6=8E=A5=E5=8F=A3=E5=81=B6=E5=8F=91=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../COSXML/Transfer/COSXMLDownloadTask.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/QCloudCSharpSDK/COSXML/Transfer/COSXMLDownloadTask.cs b/QCloudCSharpSDK/COSXML/Transfer/COSXMLDownloadTask.cs index 76a6193..85152ff 100644 --- a/QCloudCSharpSDK/COSXML/Transfer/COSXMLDownloadTask.cs +++ b/QCloudCSharpSDK/COSXML/Transfer/COSXMLDownloadTask.cs @@ -224,7 +224,7 @@ internal void Download() } // concurrent download ConcurrentGetObject(result.crc64ecma); - } + } }, @@ -462,8 +462,9 @@ private void ConcurrentGetObject(string crc64ecma) return; } // 对客户端异常, 全部都重试 - if (clientEx != null) + if (clientEx != null) { gClientExp = clientEx; + } resetEvent.Set(); } ); @@ -528,7 +529,7 @@ 超出 singleTaskTimeoutMs 时,全部清理掉进入下一轮重试 } } return; - } + } // 预期每个分块都下载完成了, 开始顺序合并 FileMode fileMode = FileMode.OpenOrCreate; FileInfo localFileInfo = new FileInfo(localDir + localFileName); @@ -672,18 +673,10 @@ private void RealCancle() // 停止可能进行中的Head请求 cosXmlServer.Cancel(headObjectRequest); // 停止可能进行中的下载线程 - Interlocked.Decrement(ref activeTasks); foreach (GetObjectRequest subGetObjectRequest in getObjectRequestsList) { cosXmlServer.Cancel(subGetObjectRequest); } - activeTasks = 0; - /* - // wait for tasks to finish - while (activeTasks > 0) - { - Thread.Sleep(100); - } - */ + getObjectRequestsList.Clear(); } private void Clear() @@ -711,7 +704,7 @@ public override void Pause() { //exit download lock (syncExit) - { + { isExit = true; } //cancle request