This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-13
lines changed
src/System.Threading.Tasks/tests/System.Runtime.CompilerServices Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -434,22 +434,16 @@ public static void RunAsyncAdditionalBehaviorsTests_NegativeCases2()
434
434
cts . Cancel ( ) ;
435
435
b . SignalAndWait ( ) ; // release task to complete
436
436
437
- // A TCS task
438
- var tcs = new TaskCompletionSource < int > ( ) ;
439
- tcs . SetCanceled ( ) ;
440
- Task t2 = tcs . Task ;
441
-
442
- EventHandler < UnobservedTaskExceptionEventArgs > handler = ( s , e ) =>
443
- {
444
- Assert . True ( false , string . Format ( " > OCE shouldn't have resulted in unobserved event firing with " + e . Exception . ToString ( ) ) ) ;
445
- } ;
437
+ // This test may be run concurrently with other tests in the suite,
438
+ // which can be problematic as TaskScheduler.UnobservedTaskException
439
+ // is global state. The handler is carefully written to be non-problematic
440
+ // if it happens to be set during the execution of another test that has
441
+ // an unobserved exception.
442
+ EventHandler < UnobservedTaskExceptionEventArgs > handler =
443
+ ( s , e ) => Assert . DoesNotContain ( oce , e . Exception . InnerExceptions ) ;
446
444
TaskScheduler . UnobservedTaskException += handler ;
447
-
448
445
( ( IAsyncResult ) t1 ) . AsyncWaitHandle . WaitOne ( ) ;
449
- ( ( IAsyncResult ) t2 ) . AsyncWaitHandle . WaitOne ( ) ;
450
446
t1 = null ;
451
- t2 = null ;
452
-
453
447
for ( int i = 0 ; i < 10 ; i ++ )
454
448
{
455
449
GC . Collect ( ) ;
You can’t perform that action at this time.
0 commit comments