File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
src/Controls/tests/DeviceTests/Elements/CollectionView Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,7 @@ public async Task CollectionViewDoesNotLeakWithDefaultItemsLayout()
257257 SetupBuilder ( ) ;
258258
259259 WeakReference weakCollectionView = null ;
260+ WeakReference weakHandler = null ;
260261
261262 await InvokeOnMainThreadAsync ( async ( ) =>
262263 {
@@ -274,15 +275,21 @@ await InvokeOnMainThreadAsync(async () =>
274275 // Verify handler is created
275276 Assert . NotNull ( handler ) ;
276277
278+ // Store weak reference to the handler
279+ weakHandler = new WeakReference ( handler ) ;
280+
277281 // Disconnect the handler
278282 ( ( IElementHandler ) handler ) . DisconnectHandler ( ) ;
279283 } ) ;
280284
281285 // Force garbage collection
282- await AssertionExtensions . WaitForGC ( weakCollectionView ) ;
286+ await AssertionExtensions . WaitForGC ( weakCollectionView , weakHandler ) ;
283287
284288 // Verify the CollectionView was collected
285289 Assert . False ( weakCollectionView . IsAlive , "CollectionView should have been garbage collected" ) ;
290+
291+ // Verify the handler was collected
292+ Assert . False ( weakHandler . IsAlive , "CollectionViewHandler2 should have been garbage collected" ) ;
286293 }
287294
288295 /// <summary>
You can’t perform that action at this time.
0 commit comments