diff --git a/dotnet/samples/Durable/Workflow/ConsoleApps/05_WorkflowEvents/Executors.cs b/dotnet/samples/Durable/Workflow/ConsoleApps/05_WorkflowEvents/Executors.cs index e9980f6445..47880f0fff 100644 --- a/dotnet/samples/Durable/Workflow/ConsoleApps/05_WorkflowEvents/Executors.cs +++ b/dotnet/samples/Durable/Workflow/ConsoleApps/05_WorkflowEvents/Executors.cs @@ -40,7 +40,7 @@ internal sealed record Order(string Id, DateTime OrderDate, bool IsCancelled, st internal sealed record Customer(string Name, string Email); // ═══════════════════════════════════════════════════════════════════════════════ -// Executors - emit events via IWorkflowContext.AddEventAsync +// Executors - emit events via AddEventAsync and YieldOutputAsync // ═══════════════════════════════════════════════════════════════════════════════ /// @@ -67,6 +67,9 @@ internal sealed class OrderLookup() : Executor("OrderLookup") await context.AddEventAsync(new OrderFoundEvent(order.Customer.Name), cancellationToken); + // YieldOutputAsync emits a WorkflowOutputEvent observable via streaming + await context.YieldOutputAsync(order, cancellationToken); + return order; } } @@ -96,6 +99,8 @@ internal sealed class OrderCancel() : Executor("OrderCancel") await context.AddEventAsync(new CancellationProgressEvent(100, "Complete"), cancellationToken); await context.AddEventAsync(new OrderCancelledEvent(), cancellationToken); + await context.YieldOutputAsync(cancelledOrder, cancellationToken); + return cancelledOrder; } } @@ -117,6 +122,8 @@ internal sealed class SendEmail() : Executor("SendEmail") await context.AddEventAsync(new EmailSentEvent(message.Customer.Email), cancellationToken); + await context.YieldOutputAsync(result, cancellationToken); + return result; } }