@@ -36,34 +36,30 @@ public static void Test1()
3636 {
3737 Console . WriteLine ( "Beginning LazyList concurrency test." ) ;
3838 var sw = new Stopwatch ( ) ;
39- using ( var list = new LazyList < TestEntry > ( EndlessTest ( ) ) )
39+ using var list = new LazyList < TestEntry > ( EndlessTest ( ) ) ;
40+ Parallel . For ( 0 , 10000000 , i =>
4041 {
41- Parallel . For ( 0 , 10000000 , i =>
42- {
43- // ReSharper disable once AccessToDisposedClosure
44- var e = list [ i ] ;
45- if ( e == null ) throw new NullReferenceException ( ) ;
46- Debug . Assert ( e . Value == i ) ;
47- } ) ;
48- Console . WriteLine ( sw . Elapsed ) ;
49- Debug . Assert ( list . IndexOf ( list [ 10000 ] ) == 10000 ) ;
50- }
42+ // ReSharper disable once AccessToDisposedClosure
43+ var e = list [ i ] ;
44+ if ( e == null ) throw new NullReferenceException ( ) ;
45+ Debug . Assert ( e . Value == i ) ;
46+ } ) ;
47+ Console . WriteLine ( sw . Elapsed ) ;
48+ Debug . Assert ( list . IndexOf ( list [ 10000 ] ) == 10000 ) ;
5149
5250 }
5351
5452 public static void Test2 ( )
5553 {
5654 Console . WriteLine ( "Beginning LazyList.GetEnumerator() concurrency test." ) ;
57- using ( var list = new LazyList < TestEntry > ( EndlessTest ( 10000000 ) ) )
55+ using var list = new LazyList < TestEntry > ( EndlessTest ( 10000000 ) ) ;
56+ var sw = new Stopwatch ( ) ;
57+ Parallel . ForEach ( list , e =>
5858 {
59- var sw = new Stopwatch ( ) ;
60- Parallel . ForEach ( list , e =>
61- {
62- if ( e == null ) throw new NullReferenceException ( ) ;
63- } ) ;
64- Console . WriteLine ( sw . Elapsed ) ;
65- Debug . Assert ( list . IndexOf ( list [ 10000 ] ) == 10000 ) ;
66- }
59+ if ( e == null ) throw new NullReferenceException ( ) ;
60+ } ) ;
61+ Console . WriteLine ( sw . Elapsed ) ;
62+ Debug . Assert ( list . IndexOf ( list [ 10000 ] ) == 10000 ) ;
6763
6864 }
6965
0 commit comments