@@ -221,15 +221,27 @@ private void ParseComponents(List<IVBComponent> components, CancellationToken to
221
221
options . CancellationToken = token ;
222
222
options . MaxDegreeOfParallelism = _maxDegreeOfParserParallelism ;
223
223
224
- Parallel . ForEach ( components ,
225
- options ,
226
- component =>
224
+ try
225
+ {
226
+ Parallel . ForEach ( components ,
227
+ options ,
228
+ component =>
229
+ {
230
+ State . ClearStateCache ( component ) ;
231
+ var finishedParseTask = FinishedParseComponentTask ( component , token ) ;
232
+ ProcessComponentParseResults ( component , finishedParseTask ) ;
233
+ }
234
+ ) ;
235
+ }
236
+ catch ( AggregateException exception )
237
+ {
238
+ if ( exception . Flatten ( ) . InnerExceptions . All ( ex => ex is OperationCanceledException ) )
227
239
{
228
- State . ClearStateCache ( component ) ;
229
- var finishedParseTask = FinishedParseComponentTask ( component , token ) ;
230
- ProcessComponentParseResults ( component , finishedParseTask ) ;
240
+ return ;
231
241
}
232
- ) ;
242
+ throw ;
243
+ }
244
+
233
245
State . EvaluateParserState ( ) ;
234
246
}
235
247
@@ -299,22 +311,43 @@ private void ResolveAllDeclarations(List<IVBComponent> components, CancellationT
299
311
var options = new ParallelOptions ( ) ;
300
312
options . CancellationToken = token ;
301
313
options . MaxDegreeOfParallelism = _maxDegreeOfParserParallelism ;
302
-
303
- Parallel . ForEach ( components ,
304
- options ,
305
- component =>
314
+ try
315
+ {
316
+ Parallel . ForEach ( components ,
317
+ options ,
318
+ component =>
319
+ {
320
+ var qualifiedName = new QualifiedModuleName ( component ) ;
321
+ ResolveDeclarations ( qualifiedName . Component ,
322
+ State . ParseTrees . Find ( s => s . Key == qualifiedName ) . Value ) ;
323
+ }
324
+ ) ;
325
+ }
326
+ catch ( AggregateException exception )
327
+ {
328
+ if ( exception . Flatten ( ) . InnerExceptions . All ( ex => ex is OperationCanceledException ) )
306
329
{
307
- var qualifiedName = new QualifiedModuleName ( component ) ;
308
- ResolveDeclarations ( qualifiedName . Component ,
309
- State . ParseTrees . Find ( s => s . Key == qualifiedName ) . Value ) ;
330
+ return ;
310
331
}
311
- ) ;
332
+ throw ;
333
+ }
312
334
}
313
335
314
336
315
337
private void ResolveReferences ( CancellationToken token )
316
338
{
317
- Task . WaitAll ( ResolveReferencesAsync ( token ) ) ;
339
+ try
340
+ {
341
+ Task . WaitAll ( ResolveReferencesAsync ( token ) ) ;
342
+ }
343
+ catch ( AggregateException exception )
344
+ {
345
+ if ( exception . Flatten ( ) . InnerExceptions . All ( ex => ex is OperationCanceledException ) )
346
+ {
347
+ return ;
348
+ }
349
+ throw ;
350
+ }
318
351
}
319
352
320
353
0 commit comments