mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Cleaning thread management of tasks
This commit is contained in:
parent
a11c281bcb
commit
62753b20bb
@ -30,6 +30,14 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
|
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
ReloadTask();
|
||||||
|
|
||||||
|
IEnumerable<ITask> startupTasks = _tasks.Select(x => x.task)
|
||||||
|
.Where(x => x.RunOnStartup && x.Priority != Int32.MaxValue)
|
||||||
|
.OrderByDescending(x => x.Priority);
|
||||||
|
foreach (ITask task in startupTasks)
|
||||||
|
_queuedTasks.Enqueue((task, null));
|
||||||
|
|
||||||
while (!cancellationToken.IsCancellationRequested)
|
while (!cancellationToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
if (_queuedTasks.Any())
|
if (_queuedTasks.Any())
|
||||||
@ -63,14 +71,8 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
public override Task StartAsync(CancellationToken cancellationToken)
|
public override Task StartAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ReloadTask();
|
Task.Run(() => base.StartAsync(cancellationToken));
|
||||||
|
return Task.CompletedTask;
|
||||||
IEnumerable<ITask> startupTasks = _tasks.Select(x => x.task)
|
|
||||||
.Where(x => x.RunOnStartup && x.Priority != Int32.MaxValue)
|
|
||||||
.OrderByDescending(x => x.Priority);
|
|
||||||
foreach (ITask task in startupTasks)
|
|
||||||
_queuedTasks.Enqueue((task, null));
|
|
||||||
return base.StartAsync(cancellationToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task StopAsync(CancellationToken cancellationToken)
|
public override Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user