mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Removed abort call from WorkQueue
This commit is contained in:
parent
ceebe0b745
commit
caadbb0aee
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user