DEV Community

Cover image for StepWise: A Powerful C# Workflow Engine for Task Execution
Xiaoyun Zhang
Xiaoyun Zhang

Posted on

StepWise: A Powerful C# Workflow Engine for Task Execution

What is StepWise

StepWise is a workflow engine that lets C# developers:

  • Code workflows in C#
  • View & Run workflow in Browser

Quick links

What Makes StepWise Special?

StepWise stands out by combining the power of C# with a simple, declarative approach to defining workflows. It automatically handles dependency resolution and parallel execution, making it perfect for scenarios where you need to coordinate multiple tasks efficiently.

How It Works

Here's a simple example that demonstrates StepWise's elegance. Let's say you're building a dinner preparation workflow:

// PrepareDinner.cs
public class PrepareDinner
{
    [Step]
    public async Task<string> ChopVegetables(string[] vegetables)
    {
        await Task.Delay(3000);
        return $"Chopped {string.Join(", ", vegetables)}";
    }

    [Step]
    public async Task<string> BoilWater()
    {
        await Task.Delay(2000);
        return "Boiled water";
    }

    [Step]
    [DependOn(nameof(ChopVegetables))]
    [DependOn(nameof(BoilWater))]
    public async Task<string> ServeDinner(
        [FromStep(nameof(ChopVegetables))] string[] vegetables,
        [FromStep(nameof(BoilWater))] string water)
    {
        return "Dinner ready!";
    }
}
Enter fullscreen mode Exit fullscreen mode

The magic happens through simple attributes:

  • [Step] marks methods as workflow steps
  • [DependOn] defines dependencies between steps
  • [FromStep] passes outputs from one step to another

This creates the following workflow in browser

Image description

You can find out more examples in StepWise Repo

Getting Started

Install StepWise via NuGet:

dotnet add package LittleLittleCloud.StepWise
Enter fullscreen mode Exit fullscreen mode

Install Gallery Samples

StepWise provides a list of Gallery samples for you to try out. To install gallery samples, simply run the following command:

dotnet add package LittleLittleCloud.StepWise.Gallery
Enter fullscreen mode Exit fullscreen mode

Top comments (0)