refactor : 重构异步操作模块
This commit is contained in:
+2
-16
@@ -262,14 +262,7 @@ namespace YooAsset
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
RunBatchExecution();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,14 +412,7 @@ namespace YooAsset
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
RunBatchExecution();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-8
@@ -124,14 +124,7 @@ namespace YooAsset
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
RunBatchExecution();
|
||||
}
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
|
||||
+7
-14
@@ -98,6 +98,10 @@ namespace YooAsset
|
||||
// 检测下载结果
|
||||
if (_steps == ESteps.CheckRequest)
|
||||
{
|
||||
//TODO 更新下载后台,防止无限挂起
|
||||
if (IsWaitForAsyncComplete)
|
||||
_fileSystem.DownloadBackend.Update();
|
||||
|
||||
DownloadProgress = _request.DownloadProgress;
|
||||
DownloadedBytes = _request.DownloadedBytes;
|
||||
Progress = DownloadProgress;
|
||||
@@ -177,23 +181,12 @@ namespace YooAsset
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
if (_request != null)
|
||||
_request.AbortRequest();
|
||||
_request.Dispose();
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//TODO 更新下载后台,防止无限挂起
|
||||
_fileSystem.DownloadBackend.Update();
|
||||
|
||||
//TODO 等待导入或解压本地文件完毕,该操作会挂起主线程!
|
||||
InternalUpdate();
|
||||
if (IsDone)
|
||||
break;
|
||||
|
||||
//TODO 短暂休眠避免完全卡死
|
||||
System.Threading.Thread.Sleep(1);
|
||||
}
|
||||
//TODO 等待导入或解压本地文件完毕,该操作会挂起主线程!
|
||||
RunUntilCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -144,7 +144,7 @@ namespace YooAsset
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
if (_request != null)
|
||||
_request.AbortRequest();
|
||||
_request.Dispose();
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
|
||||
+7
-14
@@ -119,23 +119,16 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 中止所有下载任务
|
||||
/// </summary>
|
||||
public void AbortAll()
|
||||
{
|
||||
foreach (var valuePair in _downloaders)
|
||||
{
|
||||
valuePair.Value.AbortOperation();
|
||||
}
|
||||
_downloaders.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源
|
||||
/// 释放下载资源
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
AbortAll();
|
||||
foreach (var valuePair in _downloaders)
|
||||
{
|
||||
var operation = valuePair.Value;
|
||||
operation.AbortOperation();
|
||||
}
|
||||
_downloaders.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+2
-10
@@ -69,16 +69,8 @@ namespace YooAsset
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//TODO 等待子线程验证文件完毕,该操作会挂起主线程!
|
||||
InternalUpdate();
|
||||
if (IsDone)
|
||||
break;
|
||||
|
||||
//TODO 短暂休眠避免完全卡死
|
||||
System.Threading.Thread.Sleep(1);
|
||||
}
|
||||
//TODO 等待子线程验证文件完毕,该操作会挂起主线程!
|
||||
RunUntilCompletion();
|
||||
}
|
||||
|
||||
private void VerifyInThread(object obj)
|
||||
|
||||
Reference in New Issue
Block a user