public void Build(IWorkflowBuilder builder) { builder .SetVariable("SignalUrl", context => context.GenerateSignalUrl("hurry")) .WriteLine(context => $"The demo completes in {_timeOut.ToString()} ({_clock.GetCurrentInstant().Plus(_timeOut)}). Can't wait that long? Send me the secret \"hurry\" signal! ({context.GetVariable<string>("SignalUrl")})") .Then <Fork>( fork => fork.WithBranches("Timer", "Signal"), fork => { fork .When("Timer") .Timer(_timeOut) .SetVariable("CompletedVia", "Timer") .ThenNamed("Join"); fork .When("Signal") .SignalReceived("hurry") .SetVariable("CompletedVia", "Signal") .ThenNamed("Join"); }) .Add <Join>(x => x.WithMode(Join.JoinMode.WaitAny)).WithName("Join") .WriteLine(context => $"Demo {GetCorrelationId(context)} completed successfully via {context.GetVariable<string>("CompletedVia")}!"); }
public void Build(IWorkflowBuilder builder) { builder .SetVariable("Count", 0) .While(true, iteration => iteration.WriteLine(context => { var count = context.SetVariable <int>("Count", x => x + 1); return($"Iteration {count}"); })) .WriteLine("This will never execute"); }
public void Build(IWorkflowBuilder builder) { builder .SetVariable("Count", context => (long)context.Input !) .WriteLine(context => $"Child workflow counting down from {context.GetVariable<long>("Count")} to 0") .For( context => context.GetVariable <long>("Count"), _ => 0, _ => - 1, iterate => { iterate.WriteLine(context => $"{context.Input}"); }, Operator.GreaterThanOrEqual) .WriteLine("Done. Back to you, parent workflow!"); }