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)
3131
3232 public override void RunSynchronously ( )
3333 {
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+
3644 base . RunSynchronously ( ) ;
3745 }
3846
3947 protected override void Schedule ( )
4048 {
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+
4359 base . Schedule ( ) ;
4460 }
4561
@@ -115,15 +131,31 @@ public ITask<TTaskResult> Queue(ITask<TTaskResult> task)
115131
116132 public override List < TResult > RunSynchronously ( )
117133 {
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+
120144 return base . RunSynchronously ( ) ;
121145 }
122146
123147 protected override void Schedule ( )
124148 {
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+
127159 base . Schedule ( ) ;
128160 }
129161
You can’t perform that action at this time.
0 commit comments