Skip to content

Commit d2a48e9

Browse files
committed
replaced redundant CTS
1 parent 3064445 commit d2a48e9

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Tools/AutoClient/Modes/FolderStore/FolderSaver.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public FolderSaver(App app, LoadBalancer loadBalancer)
2323
status = statusFile.Load();
2424
}
2525

26-
public void Run(CancellationTokenSource cts)
26+
public void Run()
2727
{
2828
var folderFiles = Directory.GetFiles(app.Config.FolderToStore);
2929
if (!folderFiles.Any()) throw new Exception("No files found in " + app.Config.FolderToStore);
@@ -32,7 +32,7 @@ public void Run(CancellationTokenSource cts)
3232
balanceChecker.Check();
3333
foreach (var folderFile in folderFiles)
3434
{
35-
if (cts.IsCancellationRequested) return;
35+
if (app.Cts.IsCancellationRequested) return;
3636
loadBalancer.CheckErrors();
3737

3838
if (!folderFile.ToLowerInvariant().EndsWith(FolderSaverFilename))
@@ -43,7 +43,7 @@ public void Run(CancellationTokenSource cts)
4343
if (failureCount > 3)
4444
{
4545
app.Log.Error("Failure count reached threshold. Stopping...");
46-
cts.Cancel();
46+
app.Cts.Cancel();
4747
return;
4848
}
4949

Tools/AutoClient/Modes/FolderStoreMode.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace AutoClient.Modes
55
public class FolderStoreMode
66
{
77
private readonly App app;
8-
private readonly CancellationTokenSource cts = new CancellationTokenSource();
98
private Task checkTask = Task.CompletedTask;
109
private readonly LoadBalancer loadBalancer;
1110

@@ -22,9 +21,9 @@ public void Start()
2221
try
2322
{
2423
var saver = new FolderSaver(app, loadBalancer);
25-
while (!cts.IsCancellationRequested)
24+
while (!app.Cts.IsCancellationRequested)
2625
{
27-
saver.Run(cts);
26+
saver.Run();
2827
}
2928
}
3029
catch (Exception ex)
@@ -37,7 +36,7 @@ public void Start()
3736

3837
public void Stop()
3938
{
40-
cts.Cancel();
39+
app.Cts.Cancel();
4140
checkTask.Wait();
4241
}
4342
}

0 commit comments

Comments
 (0)