@@ -111,38 +111,42 @@ await this.SetErrorAsync(new()
111
111
} ;
112
112
this . Subflow = await this . Api . WorkflowInstances . CreateAsync ( this . Subflow , cancellationToken ) . ConfigureAwait ( false ) ;
113
113
}
114
- await foreach ( var watchEvent in this . Api . WorkflowInstances . MonitorAsync ( this . Subflow . GetName ( ) , this . Subflow . GetNamespace ( ) ! , cancellationToken ) )
114
+ if ( this . Task . Definition . Run . Await == false ) await this . SetResultAsync ( new ( ) , this . Task . Definition . Then , cancellationToken ) . ConfigureAwait ( false ) ;
115
+ else
115
116
{
116
- switch ( watchEvent . Resource . Status ? . Phase )
117
+ await foreach ( var watchEvent in this . Api . WorkflowInstances . MonitorAsync ( this . Subflow . GetName ( ) , this . Subflow . GetNamespace ( ) ! , cancellationToken ) )
117
118
{
118
- case WorkflowInstanceStatusPhase . Cancelled :
119
- if ( ! this . Cancelling )
120
- {
121
- await this . SetErrorAsync ( new ( )
119
+ switch ( watchEvent . Resource . Status ? . Phase )
120
+ {
121
+ case WorkflowInstanceStatusPhase . Cancelled :
122
+ if ( ! this . Cancelling )
122
123
{
123
- Type = ErrorType . Runtime ,
124
- Status = ErrorStatus . Runtime ,
125
- Title = ErrorTitle . Runtime ,
126
- Detail = $ "The execution of workflow instance '{ this . Subflow . GetQualifiedName ( ) } ' has been cancelled"
127
- } , cancellationToken ) . ConfigureAwait ( false ) ;
128
- }
129
- break ;
130
- case WorkflowInstanceStatusPhase . Faulted :
131
- await this . SetErrorAsync ( watchEvent . Resource . Status . Error ! , cancellationToken ) . ConfigureAwait ( false ) ;
132
- return ;
133
- case WorkflowInstanceStatusPhase . Completed :
134
- var output = string . IsNullOrWhiteSpace ( watchEvent . Resource . Status ? . OutputReference ) ? null : ( await this . Api . Documents . GetAsync ( watchEvent . Resource . Status . OutputReference , cancellationToken ) . ConfigureAwait ( false ) ) . Content ;
135
- await this . SetResultAsync ( output , this . Task . Definition . Then , cancellationToken ) . ConfigureAwait ( false ) ;
136
- return ;
124
+ await this . SetErrorAsync ( new ( )
125
+ {
126
+ Type = ErrorType . Runtime ,
127
+ Status = ErrorStatus . Runtime ,
128
+ Title = ErrorTitle . Runtime ,
129
+ Detail = $ "The execution of workflow instance '{ this . Subflow . GetQualifiedName ( ) } ' has been cancelled"
130
+ } , cancellationToken ) . ConfigureAwait ( false ) ;
131
+ }
132
+ break ;
133
+ case WorkflowInstanceStatusPhase . Faulted :
134
+ await this . SetErrorAsync ( watchEvent . Resource . Status . Error ! , cancellationToken ) . ConfigureAwait ( false ) ;
135
+ return ;
136
+ case WorkflowInstanceStatusPhase . Completed :
137
+ var output = string . IsNullOrWhiteSpace ( watchEvent . Resource . Status ? . OutputReference ) ? null : ( await this . Api . Documents . GetAsync ( watchEvent . Resource . Status . OutputReference , cancellationToken ) . ConfigureAwait ( false ) ) . Content ;
138
+ await this . SetResultAsync ( output , this . Task . Definition . Then , cancellationToken ) . ConfigureAwait ( false ) ;
139
+ return ;
140
+ }
141
+ if ( this . Cancelling ) break ;
137
142
}
138
- if ( this . Cancelling ) break ;
139
143
}
140
144
}
141
145
142
146
/// <inheritdoc/>
143
147
public override async Task CancelAsync ( CancellationToken cancellationToken = default )
144
148
{
145
- if ( this . Subflow != null )
149
+ if ( this . Subflow != null && this . Task . Definition . Run . Await != false )
146
150
{
147
151
try
148
152
{
0 commit comments