简单的修改
This commit is contained in:
@@ -62,11 +62,12 @@ namespace FATrace.OEMApp.Services
|
||||
var maxRetry = ConfigHelper.GetIntOrDefault("DownloadTaskMaxRetry", 3);
|
||||
db.Update<DownloadTask>()
|
||||
.Set(a => a.Status, TaskStatus.Pending)
|
||||
.Set(a => a.Error, null)
|
||||
.Set(a => a.Error, "")
|
||||
.Set(a => a.Progress, 0)
|
||||
.Set(a => a.UpdateTime, DateTime.Now)
|
||||
.Where(a => a.Status == TaskStatus.Failed && a.TryCount < maxRetry)
|
||||
.ExecuteAffrows();
|
||||
|
||||
}
|
||||
catch { }
|
||||
_cts = new CancellationTokenSource();
|
||||
@@ -125,9 +126,9 @@ namespace FATrace.OEMApp.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 后台主循环:定期拉取最早的 Pending 任务并顺序处理。
|
||||
/// 后台主循环:定期拉取最早的 Pending 任务并顺序处理
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌。</param>
|
||||
/// <param name="token">取消令牌</param>
|
||||
private async Task RunAsync(CancellationToken token)
|
||||
{
|
||||
while (!token.IsCancellationRequested)
|
||||
@@ -211,8 +212,9 @@ namespace FATrace.OEMApp.Services
|
||||
.ExecuteAffrowsAsync();
|
||||
|
||||
// 事件 -> TCS
|
||||
// 订阅两个事件:进度与完成。进度事件写回数据库;完成事件用于唤醒等待。
|
||||
// 订阅两个事件:进度与完成。进度事件写回数据库;完成事件用于唤醒等待
|
||||
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
void OnProgress(object? s, short p)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user