Skip to content

Commit 3e7161f

Browse files
Copilotweiyuanyue
andauthored
Fix SA1214 and IDISP003 analyzer violations in SampleContainer (#564)
* Initial plan * Fix SA1214 and IDISP003 analyzer errors in SampleContainer Co-authored-by: weiyuanyue <176483933+weiyuanyue@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weiyuanyue <176483933+weiyuanyue@users.noreply.github.com>
1 parent d8aa456 commit 3e7161f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

AIDevGallery/Controls/SampleContainer.xaml.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ public List<string> NugetPackageReferences
5858
public static readonly DependencyProperty NugetPackageReferencesProperty =
5959
DependencyProperty.Register("NugetPackageReferences", typeof(List<string>), typeof(SampleContainer), new PropertyMetadata(null));
6060

61+
private readonly object _ctsLock = new object();
6162
private RichTextBlockFormatter codeFormatter;
6263
private Dictionary<string, string> codeFiles = new();
6364
private Sample? _sampleCache;
6465
private Dictionary<ModelType, ExpandedModelDetails>? _cachedModels;
6566
private List<ModelDetails>? _modelsCache;
6667
private WinMlSampleOptions? _currentWinMlSampleOptions;
6768
private CancellationTokenSource? _sampleLoadingCts;
68-
private readonly object _ctsLock = new object();
6969
private TaskCompletionSource? _sampleLoadedCompletionSource;
7070
private double _codePaneWidth;
7171
private ModelType? _wcrApi;
@@ -119,10 +119,14 @@ private void CancelCTS()
119119

120120
if (cts != null)
121121
{
122-
using (cts)
122+
try
123123
{
124124
cts.Cancel();
125125
}
126+
finally
127+
{
128+
cts.Dispose();
129+
}
126130
}
127131
}
128132

0 commit comments

Comments
 (0)