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
14
14
{
15
15
[ Fact ]
16
16
[ QuarantinedTest ]
17
- public void FinalizerRunsIfTimerAwaitableReferencesObject ( )
17
+ public async Task FinalizerRunsIfTimerAwaitableReferencesObject ( )
18
18
{
19
19
var tcs = new TaskCompletionSource < object > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
20
20
UseTimerAwaitableAndUnref ( tcs ) ;
21
21
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 ( ) ;
28
24
29
25
// Make sure the finalizer runs
30
- Assert . True ( tcs . Task . IsCompleted ) ;
26
+ await tcs . Task . OrTimeout ( ) ;
31
27
}
32
28
33
29
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
@@ -43,12 +39,11 @@ public class ObjectWithTimerAwaitable
43
39
{
44
40
private readonly TimerAwaitable _timer ;
45
41
private readonly TaskCompletionSource < object > _tcs ;
46
- private int _count ;
47
42
48
43
public ObjectWithTimerAwaitable ( TaskCompletionSource < object > tcs )
49
44
{
50
45
_tcs = tcs ;
51
- _timer = new TimerAwaitable ( TimeSpan . Zero , TimeSpan . FromSeconds ( 1 ) ) ;
46
+ _timer = new TimerAwaitable ( TimeSpan . FromSeconds ( 30 ) , TimeSpan . FromSeconds ( 1 ) ) ;
52
47
_timer . Start ( ) ;
53
48
}
54
49
@@ -58,7 +53,6 @@ public async Task Start()
58
53
{
59
54
while ( await _timer )
60
55
{
61
- _count ++ ;
62
56
}
63
57
}
64
58
}
You can’t perform that action at this time.
0 commit comments