File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed
MongoDB.Bson.TestHelpers/Threading Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ public static async Task<Exception[]> ExecuteTasksOnNewThreadsCollectExceptions(
110
110
}
111
111
} ) ;
112
112
113
- var taskAll = Task . WhenAll ( allTasks ) ;
113
+ var taskAll = Task . WhenAll ( allTasks . Select ( t => t . Result ) ) ;
114
114
if ( await Task . WhenAny ( taskAll , Task . Delay ( timeoutMilliseconds ) ) != taskAll )
115
115
{
116
116
exceptions . Add ( new TimeoutException ( ) ) ;
Original file line number Diff line number Diff line change
1
+ using System . Threading ;
2
+ using System . Threading . Tasks ;
3
+ using MongoDB . Bson . TestHelpers ;
4
+ using MongoDB . TestHelpers . XunitExtensions ;
5
+ using Xunit ;
6
+ using Xunit . Abstractions ;
7
+
8
+ namespace MongoDB . Driver . Tests
9
+ {
10
+ // TODO: DO NOT MERGE THIS CLASS!
11
+ // It exists for problem repro purposes only
12
+ public class TestClassDoNotMerge
13
+ {
14
+ private readonly ITestOutputHelper _output ;
15
+
16
+ public TestClassDoNotMerge ( ITestOutputHelper output )
17
+ {
18
+ _output = output ;
19
+ }
20
+
21
+ [ Theory ]
22
+ [ ParameterAttributeData ]
23
+ public async Task RunTasksInParallelTest ( [ Values ( false , true ) ] bool async )
24
+ {
25
+ _output . WriteLine ( $ "Test async={ async } : before parallel") ;
26
+
27
+ await ThreadingUtilities . ExecuteTasksOnNewThreads ( 10 , async i =>
28
+ {
29
+ if ( async)
30
+ {
31
+ await Task . Delay ( 100 ) ;
32
+ }
33
+ else
34
+ {
35
+ Thread . Sleep ( 100 ) ;
36
+ }
37
+ _output . WriteLine ( $ "I'm task number { i } ") ;
38
+ } ) ;
39
+
40
+ _output . WriteLine ( $ "Test async={ async } : after parallel") ;
41
+
42
+ await Task . Delay ( 1_000 ) ;
43
+ _output. WriteLine ( $ "Test async={ async } : done") ;
44
+ }
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments