File tree Expand file tree Collapse file tree 2 files changed +19
-17
lines changed
src/NHibernate.Test/NHSpecificTest Expand file tree Collapse file tree 2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33using System . Threading ;
4+ using System . Threading . Tasks ;
45using NUnit . Framework ;
56
67namespace NHibernate . Test . NHSpecificTest . NH2192
@@ -83,22 +84,22 @@ public void HqlIsThreadsafe_UsingPool()
8384 {
8485 List < Exception > exceptions = new List < Exception > ( ) ;
8586 Func < int > result = FetchRowResults ;
86- List < IAsyncResult > results = new List < IAsyncResult > ( ) ;
87+ List < Task < int > > results = new List < Task < int > > ( ) ;
8788
88- for ( int i = 0 ; i < _threadCount ; i ++ )
89- results . Add ( result . BeginInvoke ( null , null ) ) ;
89+ for ( int i = 0 ; i < _threadCount ; i ++ )
90+ results . Add ( Task . Run < int > ( result ) ) ;
9091
9192 results . ForEach ( r =>
93+ {
94+ try
9295 {
93- try
94- {
95- Assert . That ( result . EndInvoke ( r ) , Is . EqualTo ( 2 ) ) ;
96- }
97- catch ( Exception e )
98- {
99- exceptions . Add ( e ) ;
100- }
101- } ) ;
96+ Assert . That ( r . Result , Is . EqualTo ( 2 ) ) ;
97+ }
98+ catch ( Exception e )
99+ {
100+ exceptions . Add ( e ) ;
101+ }
102+ } ) ;
102103
103104 if ( exceptions . Count > 0 )
104105 throw exceptions [ 0 ] ;
Original file line number Diff line number Diff line change 33using System . Collections . Generic ;
44using System . Reflection ;
55using System . Threading ;
6+ using System . Threading . Tasks ;
67
78using NHibernate . Engine . Query ;
89using NHibernate . Linq ;
@@ -144,11 +145,11 @@ where personIds.Contains(person.Id)
144145 }
145146 } ;
146147
147- var queryExecutorAsyncResult = queryExecutor . BeginInvoke ( null , null ) ;
148- var cacheCleanerAsyncResult = cacheCleaner . BeginInvoke ( null , null ) ;
148+ var queryExecutorAsyncResult = Task . Run ( queryExecutor ) ;
149+ var cacheCleanerAsyncResult = Task . Run ( cacheCleaner ) ;
149150
150- queryExecutor . EndInvoke ( queryExecutorAsyncResult ) ;
151- cacheCleaner . EndInvoke ( cacheCleanerAsyncResult ) ;
151+ queryExecutorAsyncResult . Wait ( ) ;
152+ cacheCleanerAsyncResult . Wait ( ) ;
152153
153154 Assert . IsTrue ( allLinqQueriesSucceeded ) ;
154155 }
@@ -161,4 +162,4 @@ where personIds.Contains(person.Id)
161162 }
162163 }
163164 }
164- }
165+ }
You can’t perform that action at this time.
0 commit comments