@@ -105,7 +105,7 @@ private async void generateButton_Click(object sender, EventArgs e)
105
105
}
106
106
107
107
// Register progression callback and ready cancellation source:
108
-
108
+
109
109
var progress = new PercentageProgressHandler ( percentage =>
110
110
{
111
111
var progressBarValue = Math . Min ( 100 , ( int ) Math . Round ( percentage * 100 , MidpointRounding . AwayFromZero ) ) ;
@@ -119,6 +119,7 @@ private async void generateButton_Click(object sender, EventArgs e)
119
119
} ) ;
120
120
121
121
_cancellationTokenSource = new CancellationTokenSource ( ) ;
122
+ var cancellationLocalRef = _cancellationTokenSource ;
122
123
123
124
// Actually create the barcode:
124
125
@@ -140,7 +141,7 @@ private async void generateButton_Click(object sender, EventArgs e)
140
141
await Task . Run ( ( ) =>
141
142
{
142
143
result = _imageProcessor . CreateBarCode ( inputPath , parameters , _ffmpegWrapper , _cancellationTokenSource . Token , progress ) ;
143
- } ) ;
144
+ } , _cancellationTokenSource . Token ) ;
144
145
}
145
146
catch ( OperationCanceledException )
146
147
{
@@ -167,6 +168,11 @@ Here is all the info available at the time of the error (press Ctrl+C to copy it
167
168
_cancellationTokenSource = null ;
168
169
}
169
170
171
+ if ( cancellationLocalRef . IsCancellationRequested )
172
+ {
173
+ return ;
174
+ }
175
+
170
176
// Save the barcode:
171
177
172
178
try
@@ -248,7 +254,8 @@ void ValidateOutputPath(ref string path)
248
254
string smoothedOutputPath = null ;
249
255
if ( smoothCheckBox . Checked )
250
256
{
251
- smoothedOutputPath = $ "{ Path . GetFileNameWithoutExtension ( outputPath ) } _smoothed{ Path . GetExtension ( outputPath ) } ";
257
+ var name = $ "{ Path . GetFileNameWithoutExtension ( outputPath ) } _smoothed{ Path . GetExtension ( outputPath ) } ";
258
+ smoothedOutputPath = Path . Combine ( Path . GetDirectoryName ( outputPath ) , name ) ;
252
259
ValidateOutputPath ( ref smoothedOutputPath ) ;
253
260
}
254
261
0 commit comments