File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
src/SignalR/clients/csharp/Client/test/UnitTests Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -14,20 +14,16 @@ public class TimerAwaitableTests
1414 {
1515 [ Fact ]
1616 [ QuarantinedTest ]
17- public void FinalizerRunsIfTimerAwaitableReferencesObject ( )
17+ public async Task FinalizerRunsIfTimerAwaitableReferencesObject ( )
1818 {
1919 var tcs = new TaskCompletionSource < object > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
2020 UseTimerAwaitableAndUnref ( tcs ) ;
2121
22- // Make sure it *really* cleans up
23- for ( int i = 0 ; i < 5 && ! tcs . Task . IsCompleted ; i ++ )
24- {
25- GC . Collect ( ) ;
26- GC . WaitForPendingFinalizers ( ) ;
27- }
22+ GC . Collect ( ) ;
23+ GC . WaitForPendingFinalizers ( ) ;
2824
2925 // Make sure the finalizer runs
30- Assert . True ( tcs . Task . IsCompleted ) ;
26+ await tcs . Task . OrTimeout ( ) ;
3127 }
3228
3329 [ MethodImpl ( MethodImplOptions . NoInlining ) ]
@@ -43,12 +39,11 @@ public class ObjectWithTimerAwaitable
4339 {
4440 private readonly TimerAwaitable _timer ;
4541 private readonly TaskCompletionSource < object > _tcs ;
46- private int _count ;
4742
4843 public ObjectWithTimerAwaitable ( TaskCompletionSource < object > tcs )
4944 {
5045 _tcs = tcs ;
51- _timer = new TimerAwaitable ( TimeSpan . Zero , TimeSpan . FromSeconds ( 1 ) ) ;
46+ _timer = new TimerAwaitable ( TimeSpan . FromSeconds ( 30 ) , TimeSpan . FromSeconds ( 1 ) ) ;
5247 _timer . Start ( ) ;
5348 }
5449
@@ -58,7 +53,6 @@ public async Task Start()
5853 {
5954 while ( await _timer )
6055 {
61- _count ++ ;
6256 }
6357 }
6458 }
You can’t perform that action at this time.
0 commit comments