Skip to content

Commit 467b216

Browse files
committed
Let GC collect CancellationTokenSource to prevent System.ObjectDisposedException
1 parent 22c55c3 commit 467b216

File tree

3 files changed

+0
-10
lines changed

3 files changed

+0
-10
lines changed

Files/Files.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@
170170
<Compile Include="Converters\UInt32ToString.cs" />
171171
<Compile Include="Converters\VisiblityInvertConverter.cs" />
172172
<Compile Include="Converters\LayoutModeToBoolConverter.cs" />
173-
<Compile Include="Converters\LayoutModeToBoolConverter.cs" />
174173
<Compile Include="DataModels\ShellNewEntry.cs" />
175174
<Compile Include="Dialogs\DynamicDialog.xaml.cs">
176175
<DependentUpon>DynamicDialog.xaml</DependentUpon>

Files/ViewModels/ItemViewModel.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ public void CancelLoadAndClearFiles()
476476
public void CancelExtendedPropertiesLoading()
477477
{
478478
loadPropsCTS.Cancel();
479-
loadPropsCTS.Dispose();
480479
loadPropsCTS = new CancellationTokenSource();
481480
}
482481

@@ -921,7 +920,6 @@ public async void RapidAddItemsToCollectionAsync(string path, string previousDir
921920
{
922921
// Drop all the other waiting instances
923922
semaphoreCTS.Cancel();
924-
semaphoreCTS.Dispose();
925923
semaphoreCTS = new CancellationTokenSource();
926924

927925
IsLoadingItems = true;
@@ -1028,7 +1026,6 @@ await folders.AsyncParallelForEach(async (folder) =>
10281026

10291027
if (addFilesCTS.IsCancellationRequested)
10301028
{
1031-
addFilesCTS.Dispose();
10321029
addFilesCTS = new CancellationTokenSource();
10331030
IsLoadingItems = false;
10341031
return;
@@ -1605,7 +1602,6 @@ private void WatchForDirectoryChanges(string path)
16051602
CloseHandle(overlapped.hEvent);
16061603
operationQueue.Clear();
16071604
cts.Cancel();
1608-
cts.Dispose();
16091605
Debug.WriteLine("aWatcherAction done: {0}", rand);
16101606
});
16111607

@@ -1924,9 +1920,6 @@ private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
19241920
public void Dispose()
19251921
{
19261922
CancelLoadAndClearFiles();
1927-
addFilesCTS?.Dispose();
1928-
semaphoreCTS?.Dispose();
1929-
loadPropsCTS?.Dispose();
19301923
}
19311924
}
19321925

Files/Views/Pages/Properties.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ private void Properties_Consolidated(ApplicationView sender, ApplicationViewCons
128128
if (tokenSource != null && !tokenSource.IsCancellationRequested)
129129
{
130130
tokenSource.Cancel();
131-
tokenSource.Dispose();
132131
tokenSource = null;
133132
}
134133
}
@@ -141,7 +140,6 @@ private void PropertiesDialog_Closed(ContentDialog sender, ContentDialogClosedEv
141140
if (tokenSource != null && !tokenSource.IsCancellationRequested)
142141
{
143142
tokenSource.Cancel();
144-
tokenSource.Dispose();
145143
tokenSource = null;
146144
}
147145
propertiesDialog.Hide();

0 commit comments

Comments
 (0)