File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 3
3
using System . Linq ;
4
4
using System . Threading ;
5
5
using System . Threading . Tasks ;
6
+ using ConcurrentCollections ;
6
7
using Microsoft . Extensions . Logging ;
7
8
using WorkflowCore . Interface ;
8
9
using WorkflowCore . Models ;
@@ -54,7 +55,7 @@ private async void Execute()
54
55
{
55
56
var cancelToken = _cancellationTokenSource . Token ;
56
57
var activeTasks = new Dictionary < string , Task > ( ) ;
57
- var secondPasses = new HashSet < string > ( ) ;
58
+ var secondPasses = new ConcurrentHashSet < string > ( ) ;
58
59
59
60
while ( ! cancelToken . IsCancellationRequested )
60
61
{
@@ -83,7 +84,7 @@ private async void Execute()
83
84
continue ;
84
85
}
85
86
86
- secondPasses . Remove ( item ) ;
87
+ secondPasses . TryRemove ( item ) ;
87
88
88
89
var task = new Task ( async ( object data ) =>
89
90
{
@@ -92,7 +93,7 @@ private async void Execute()
92
93
await ExecuteItem ( ( string ) data ) ;
93
94
while ( EnableSecondPasses && secondPasses . Contains ( item ) )
94
95
{
95
- secondPasses . Remove ( item ) ;
96
+ secondPasses . TryRemove ( item ) ;
96
97
await ExecuteItem ( ( string ) data ) ;
97
98
}
98
99
}
Original file line number Diff line number Diff line change 24
24
</PropertyGroup >
25
25
26
26
<ItemGroup >
27
+ <PackageReference Include =" ConcurrentHashSet" Version =" 1.1.0" />
27
28
<PackageReference Include =" Microsoft.Extensions.DependencyInjection.Abstractions" Version =" 2.2.0" />
28
29
<PackageReference Include =" Microsoft.Extensions.Hosting.Abstractions" Version =" 2.2.0" />
29
30
<PackageReference Include =" Microsoft.Extensions.Logging.Abstractions" Version =" 2.2.0" />
You can’t perform that action at this time.
0 commit comments