Added CancellationToken renewal
This commit is contained in:
@@ -64,6 +64,12 @@ public class CallsController : ControllerBase
|
|||||||
}
|
}
|
||||||
if (callName is null)
|
if (callName is null)
|
||||||
{
|
{
|
||||||
|
if (worker.ScriptContainer.ToolSet.CancellationToken.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
worker.CancellationTokenSource.Dispose();
|
||||||
|
worker.CancellationTokenSource = new CancellationTokenSource();
|
||||||
|
worker.ScriptContainer.ToolSet.CancellationToken = worker.CancellationTokenSource.Token;
|
||||||
|
}
|
||||||
_logger.LogInformation("Starting calls in worker {workerName}.", [workerName]);
|
_logger.LogInformation("Starting calls in worker {workerName}.", [workerName]);
|
||||||
foreach (ICall call in worker.Calls)
|
foreach (ICall call in worker.Calls)
|
||||||
{
|
{
|
||||||
@@ -81,6 +87,12 @@ public class CallsController : ControllerBase
|
|||||||
return new CallEnableResult { Success = false };
|
return new CallEnableResult { Success = false };
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Starting call {callName} in worker {workerName}.", [callName, workerName]);
|
_logger.LogInformation("Starting call {callName} in worker {workerName}.", [callName, workerName]);
|
||||||
|
if (worker.ScriptContainer.ToolSet.CancellationToken.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
worker.CancellationTokenSource.Dispose();
|
||||||
|
worker.CancellationTokenSource = new CancellationTokenSource();
|
||||||
|
worker.ScriptContainer.ToolSet.CancellationToken = worker.CancellationTokenSource.Token;
|
||||||
|
}
|
||||||
call.Enable();
|
call.Enable();
|
||||||
}
|
}
|
||||||
return new CallEnableResult { Success = true };
|
return new CallEnableResult { Success = true };
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ public class Worker
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public WorkerConfig Config { get; set; }
|
public WorkerConfig Config { get; set; }
|
||||||
public IScriptContainer ScriptContainer { get; set; }
|
public IScriptContainer ScriptContainer { get; set; }
|
||||||
public CancellationTokenSource CancellationTokenSource { get; }
|
public CancellationTokenSource CancellationTokenSource { get; set; }
|
||||||
public List<ICall> Calls { get; set; }
|
public List<ICall> Calls { get; set; }
|
||||||
public bool IsExecuting { get; set; }
|
public bool IsExecuting { get; set; }
|
||||||
public DateTime? LastExecution { get; set; }
|
public DateTime? LastExecution { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user