This repository was archived by the owner on Dec 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +40
-8
lines changed Expand file tree Collapse file tree 1 file changed +40
-8
lines changed Original file line number Diff line number Diff line change @@ -31,15 +31,31 @@ public ITask Queue(ITask task)
31
31
32
32
public override void RunSynchronously ( )
33
33
{
34
- foreach ( var task in queuedTasks )
35
- task . Start ( ) ;
34
+ if ( queuedTasks . Any ( ) )
35
+ {
36
+ foreach ( var task in queuedTasks )
37
+ task . Start ( ) ;
38
+ }
39
+ else
40
+ {
41
+ aggregateTask . TrySetResult ( true ) ;
42
+ }
43
+
36
44
base . RunSynchronously ( ) ;
37
45
}
38
46
39
47
protected override void Schedule ( )
40
48
{
41
- foreach ( var task in queuedTasks )
42
- task . Start ( ) ;
49
+ if ( queuedTasks . Any ( ) )
50
+ {
51
+ foreach ( var task in queuedTasks )
52
+ task . Start ( ) ;
53
+ }
54
+ else
55
+ {
56
+ aggregateTask . TrySetResult ( true ) ;
57
+ }
58
+
43
59
base . Schedule ( ) ;
44
60
}
45
61
@@ -115,15 +131,31 @@ public ITask<TTaskResult> Queue(ITask<TTaskResult> task)
115
131
116
132
public override List < TResult > RunSynchronously ( )
117
133
{
118
- foreach ( var task in queuedTasks )
119
- task . Start ( ) ;
134
+ if ( queuedTasks . Any ( ) )
135
+ {
136
+ foreach ( var task in queuedTasks )
137
+ task . Start ( ) ;
138
+ }
139
+ else
140
+ {
141
+ aggregateTask . TrySetResult ( new List < TResult > ( ) ) ;
142
+ }
143
+
120
144
return base . RunSynchronously ( ) ;
121
145
}
122
146
123
147
protected override void Schedule ( )
124
148
{
125
- foreach ( var task in queuedTasks )
126
- task . Start ( ) ;
149
+ if ( queuedTasks . Any ( ) )
150
+ {
151
+ foreach ( var task in queuedTasks )
152
+ task . Start ( ) ;
153
+ }
154
+ else
155
+ {
156
+ aggregateTask . TrySetResult ( new List < TResult > ( ) ) ;
157
+ }
158
+
127
159
base . Schedule ( ) ;
128
160
}
129
161
You can’t perform that action at this time.
0 commit comments