Move adding jobs to context to Job.Run (from Tranga.cs)

This commit is contained in:
Glax 2025-03-13 20:06:46 +01:00
parent cc03b6fa9c
commit 19ff3f578a
2 changed files with 2 additions and 2 deletions

View File

@ -58,8 +58,9 @@ public abstract class Job
this.state = JobState.Running;
context.SaveChanges();
IEnumerable<Job> newJobs = RunInternal(context);
Job[] newJobs = RunInternal(context).ToArray();
this.state = JobState.Completed;
context.Jobs.AddRange(newJobs);
context.SaveChanges();
return newJobs;
}

View File

@ -113,7 +113,6 @@ public static class Tranga
Thread t = new(() =>
{
IEnumerable<Job> newJobs = job.Run(serviceProvider);
context.Jobs.AddRange(newJobs);
});
RunningJobs.Add(t, job);
t.Start();