Fix task finished before Finish-Action could be set.

This commit is contained in:
2025-09-02 01:30:41 +02:00
parent 1b0aa7d543
commit 6fa166363a

View File

@@ -89,9 +89,10 @@ public abstract class BaseWorker : Identifiable
// Run the actual work // Run the actual work
Log.Info($"Running {this}"); Log.Info($"Running {this}");
DateTime startTime = DateTime.UtcNow; DateTime startTime = DateTime.UtcNow;
Task<BaseWorker[]> task = DoWorkInternal(); Task<BaseWorker[]> task = new Task<BaseWorker[]>(() => DoWorkInternal().Result);
task.GetAwaiter().OnCompleted(Finish(startTime, callback)); task.GetAwaiter().OnCompleted(Finish(startTime, callback));
this.State = WorkerExecutionState.Running; this.State = WorkerExecutionState.Running;
task.Start();
return task; return task;
} }