File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public FolderSaver(App app, LoadBalancer loadBalancer)
23
23
status = statusFile . Load ( ) ;
24
24
}
25
25
26
- public void Run ( CancellationTokenSource cts )
26
+ public void Run ( )
27
27
{
28
28
var folderFiles = Directory . GetFiles ( app . Config . FolderToStore ) ;
29
29
if ( ! folderFiles . Any ( ) ) throw new Exception ( "No files found in " + app . Config . FolderToStore ) ;
@@ -32,7 +32,7 @@ public void Run(CancellationTokenSource cts)
32
32
balanceChecker . Check ( ) ;
33
33
foreach ( var folderFile in folderFiles )
34
34
{
35
- if ( cts . IsCancellationRequested ) return ;
35
+ if ( app . Cts . IsCancellationRequested ) return ;
36
36
loadBalancer . CheckErrors ( ) ;
37
37
38
38
if ( ! folderFile . ToLowerInvariant ( ) . EndsWith ( FolderSaverFilename ) )
@@ -43,7 +43,7 @@ public void Run(CancellationTokenSource cts)
43
43
if ( failureCount > 3 )
44
44
{
45
45
app . Log . Error ( "Failure count reached threshold. Stopping..." ) ;
46
- cts . Cancel ( ) ;
46
+ app . Cts . Cancel ( ) ;
47
47
return ;
48
48
}
49
49
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ namespace AutoClient.Modes
5
5
public class FolderStoreMode
6
6
{
7
7
private readonly App app ;
8
- private readonly CancellationTokenSource cts = new CancellationTokenSource ( ) ;
9
8
private Task checkTask = Task . CompletedTask ;
10
9
private readonly LoadBalancer loadBalancer ;
11
10
@@ -22,9 +21,9 @@ public void Start()
22
21
try
23
22
{
24
23
var saver = new FolderSaver ( app , loadBalancer ) ;
25
- while ( ! cts . IsCancellationRequested )
24
+ while ( ! app . Cts . IsCancellationRequested )
26
25
{
27
- saver . Run ( cts ) ;
26
+ saver . Run ( ) ;
28
27
}
29
28
}
30
29
catch ( Exception ex )
@@ -37,7 +36,7 @@ public void Start()
37
36
38
37
public void Stop ( )
39
38
{
40
- cts . Cancel ( ) ;
39
+ app . Cts . Cancel ( ) ;
41
40
checkTask . Wait ( ) ;
42
41
}
43
42
}
You can’t perform that action at this time.
0 commit comments