File tree Expand file tree Collapse file tree
test/Microsoft.VisualStudio.Threading.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,10 +153,11 @@ public async Task ValueFactoryReleasedAfterExecution()
153153 {
154154 WeakReference collectible = await this . ValueFactoryReleasedAfterExecution_Helper ( ) ;
155155
156+ await Task . Yield ( ) ;
156157 for ( int i = 0 ; i < 3 ; i ++ )
157158 {
158- await Task . Yield ( ) ;
159- GC . Collect ( ) ;
159+ GC . Collect ( GC . MaxGeneration , GCCollectionMode . Forced , blocking : true ) ;
160+ GC . WaitForPendingFinalizers ( ) ;
160161 }
161162
162163 Assert . False ( collectible . IsAlive ) ;
@@ -167,10 +168,11 @@ public async Task AsyncPumpReleasedAfterExecution(bool throwInValueFactory)
167168 {
168169 WeakReference collectible = await this . AsyncPumpReleasedAfterExecution_Helper ( throwInValueFactory ) ;
169170
171+ await Task . Yield ( ) ;
170172 for ( int i = 0 ; i < 3 ; i ++ )
171173 {
172- await Task . Yield ( ) ;
173- GC . Collect ( ) ;
174+ GC . Collect ( GC . MaxGeneration , GCCollectionMode . Forced , blocking : true ) ;
175+ GC . WaitForPendingFinalizers ( ) ;
174176 }
175177
176178 Assert . False ( collectible . IsAlive ) ;
You can’t perform that action at this time.
0 commit comments