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 1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Threading ;
4
+ using System . Threading . Tasks ;
4
5
using NUnit . Framework ;
5
6
6
7
namespace NHibernate . Test . NHSpecificTest . NH2192
@@ -83,22 +84,22 @@ public void HqlIsThreadsafe_UsingPool()
83
84
{
84
85
List < Exception > exceptions = new List < Exception > ( ) ;
85
86
Func < int > result = FetchRowResults ;
86
- List < IAsyncResult > results = new List < IAsyncResult > ( ) ;
87
+ List < Task < int > > results = new List < Task < int > > ( ) ;
87
88
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 ) ) ;
90
91
91
92
results . ForEach ( r =>
93
+ {
94
+ try
92
95
{
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
+ } ) ;
102
103
103
104
if ( exceptions . Count > 0 )
104
105
throw exceptions [ 0 ] ;
Original file line number Diff line number Diff line change 3
3
using System . Collections . Generic ;
4
4
using System . Reflection ;
5
5
using System . Threading ;
6
+ using System . Threading . Tasks ;
6
7
7
8
using NHibernate . Engine . Query ;
8
9
using NHibernate . Linq ;
@@ -144,11 +145,11 @@ where personIds.Contains(person.Id)
144
145
}
145
146
} ;
146
147
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 ) ;
149
150
150
- queryExecutor . EndInvoke ( queryExecutorAsyncResult ) ;
151
- cacheCleaner . EndInvoke ( cacheCleanerAsyncResult ) ;
151
+ queryExecutorAsyncResult . Wait ( ) ;
152
+ cacheCleanerAsyncResult . Wait ( ) ;
152
153
153
154
Assert . IsTrue ( allLinqQueriesSucceeded ) ;
154
155
}
@@ -161,4 +162,4 @@ where personIds.Contains(person.Id)
161
162
}
162
163
}
163
164
}
164
- }
165
+ }
You can’t perform that action at this time.
0 commit comments