Ignore if semaphore is used after task is cancelled
This commit is contained in:
@@ -136,9 +136,13 @@ public sealed class Solver : IDisposable
|
||||
solver.Search(Config.Iterations / Config.ForkCount, Token);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
semaphore.Release();
|
||||
}
|
||||
catch (ObjectDisposedException) { }
|
||||
}
|
||||
var solution = solver.Solution();
|
||||
var progressActions = activeStates[stateIdx].Actions.Concat(solution.Actions).Skip(definiteActionCount).ToList();
|
||||
OnWorkerProgress?.Invoke(solution with { Actions = progressActions }, solver.MaxScore);
|
||||
@@ -254,9 +258,13 @@ public sealed class Solver : IDisposable
|
||||
solver.Search(Config.Iterations / Config.ForkCount, Token);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
semaphore.Release();
|
||||
}
|
||||
catch (ObjectDisposedException) { }
|
||||
}
|
||||
var solution = solver.Solution();
|
||||
OnWorkerProgress?.Invoke(solution, solver.MaxScore);
|
||||
return (solver.MaxScore, solution);
|
||||
@@ -341,9 +349,13 @@ public sealed class Solver : IDisposable
|
||||
solver.Search(Config.Iterations / Config.ForkCount, Token);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
semaphore.Release();
|
||||
}
|
||||
catch (ObjectDisposedException) { }
|
||||
}
|
||||
var solution = solver.Solution();
|
||||
OnWorkerProgress?.Invoke(solution, solver.MaxScore);
|
||||
return (solver.MaxScore, solution);
|
||||
|
||||
Reference in New Issue
Block a user