Skip to content

Commit 643dd38

Browse files
committed
Fix SonarCloud remark
1 parent 212805f commit 643dd38

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Sdk/Tasks/DmappCreation.cs

+6-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace Skyline.DataMiner.Sdk
55
using System.Collections.Generic;
66
using System.Diagnostics;
77
using System.Linq;
8-
using System.Threading;
98

109
using Microsoft.Build.Framework;
1110

@@ -21,7 +20,7 @@ namespace Skyline.DataMiner.Sdk
2120

2221
public class DmappCreation : Task, ICancelableTask
2322
{
24-
private CancellationTokenSource _cancellationTokenSource;
23+
private bool cancel = false;
2524

2625
public string ProjectFile { get; set; }
2726
public string ProjectType { get; set; }
@@ -31,7 +30,6 @@ public class DmappCreation : Task, ICancelableTask
3130

3231
public override bool Execute()
3332
{
34-
_cancellationTokenSource = new CancellationTokenSource();
3533
Stopwatch timer = Stopwatch.StartNew();
3634

3735
try
@@ -45,7 +43,7 @@ public override bool Execute()
4543
return false;
4644
}
4745

48-
if (_cancellationTokenSource.IsCancellationRequested)
46+
if (cancel)
4947
{
5048
// Early cancel if necessary
5149
return true;
@@ -57,7 +55,7 @@ public override bool Execute()
5755
case DataMinerProjectType.AutomationScriptLibrary:
5856
case DataMinerProjectType.UserDefinedApi:
5957
case DataMinerProjectType.AdHocDataSource: // Could change in the future as this is automation script style, but doesn't behave as an automation script.
60-
AutomationScriptStyle.PackageResult automationScriptResult = AutomationScriptStyle.TryCreatePackage(preparedData).WaitAndUnwrapException(_cancellationTokenSource.Token);
58+
AutomationScriptStyle.PackageResult automationScriptResult = AutomationScriptStyle.TryCreatePackage(preparedData).WaitAndUnwrapException();
6159

6260
if (!automationScriptResult.IsSuccess)
6361
{
@@ -82,7 +80,7 @@ public override bool Execute()
8280
return false;
8381
}
8482

85-
if (_cancellationTokenSource.IsCancellationRequested)
83+
if (cancel)
8684
{
8785
return false;
8886
}
@@ -116,7 +114,7 @@ private bool TryCreateAppPackageBuilder(PackageCreationData preparedData, DataMi
116114
}
117115

118116
// Create custom install script.
119-
AutomationScriptStyle.PackageResult packageResult = AutomationScriptStyle.TryCreatePackage(preparedData, createAsTempFile: true).WaitAndUnwrapException(_cancellationTokenSource.Token);
117+
AutomationScriptStyle.PackageResult packageResult = AutomationScriptStyle.TryCreatePackage(preparedData, createAsTempFile: true).WaitAndUnwrapException();
120118

121119
if (!packageResult.IsSuccess)
122120
{
@@ -135,7 +133,7 @@ private bool TryCreateAppPackageBuilder(PackageCreationData preparedData, DataMi
135133
/// </summary>
136134
public void Cancel()
137135
{
138-
_cancellationTokenSource.Cancel();
136+
cancel = true;
139137
}
140138

141139
/// <summary>

0 commit comments

Comments
 (0)