Removed abort call from WorkQueue

This commit is contained in:
Justin Swanson 2019-12-03 18:03:43 -06:00
parent ceebe0b745
commit caadbb0aee

View File

@ -24,6 +24,8 @@ namespace Wabbajack.Common
public static List<Thread> Threads { get; private set; }
private CancellationTokenSource _cancel = new CancellationTokenSource();
public WorkQueue(int threadCount = 0)
{
StartThreads(threadCount == 0 ? Environment.ProcessorCount : threadCount);
@ -51,11 +53,17 @@ namespace Wabbajack.Common
CpuId = idx;
CurrentQueue = this;
while (true)
try
{
while (true)
{
Report("Waiting", 0, false);
var f = Queue.Take(_cancel.Token);
f();
}
}
catch (OperationCanceledException)
{
Report("Waiting", 0, false);
var f = Queue.Take();
f();
}
}
@ -79,7 +87,7 @@ namespace Wabbajack.Common
public void Shutdown()
{
Threads.Do(th => th.Abort());
_cancel.Cancel();
Threads.Do(th => th.Join());
}