File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Rubberduck.Parsing/VBA/Parsing Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
- using System . Collections . Concurrent ;
3
2
using System . Collections . Generic ;
4
3
using System . Linq ;
5
4
using System . Threading ;
@@ -30,7 +29,8 @@ public ParseRunner(
30
29
31
30
token . ThrowIfCancellationRequested ( ) ;
32
31
33
- var results = new ConcurrentBag < ( QualifiedModuleName module , ModuleParseResults results ) > ( ) ;
32
+ var results = new List < ( QualifiedModuleName module , ModuleParseResults results ) > ( ) ;
33
+ var lockObject = new object ( ) ;
34
34
35
35
var options = new ParallelOptions
36
36
{
@@ -42,7 +42,19 @@ public ParseRunner(
42
42
{
43
43
Parallel . ForEach ( modules ,
44
44
options ,
45
- module => results . Add ( ( module , ModuleParseResults ( module , token ) ) )
45
+ ( ) => new List < ( QualifiedModuleName module , ModuleParseResults results ) > ( ) ,
46
+ ( module , state , localList ) =>
47
+ {
48
+ localList . Add ( ( module , ModuleParseResults ( module , token ) ) ) ;
49
+ return localList ;
50
+ } ,
51
+ ( finalResult ) =>
52
+ {
53
+ lock ( lockObject )
54
+ {
55
+ results . AddRange ( finalResult ) ;
56
+ }
57
+ }
46
58
) ;
47
59
}
48
60
catch ( AggregateException exception )
You can’t perform that action at this time.
0 commit comments