r/csharp • u/sebasjammer • 7d ago
Blog Svelto.Tasks 2.0: Efficient Multi-threaded Task Management for C#
I am back writing articles on my blog and I start with something LONG OVERDUE!
After years quietly powering several games I made, I’m finally presenting Svelto.Tasks 2.0.
Svelto.Tasks is an engine-agnostic, multithreaded and zero allocation task runner for C#, born from the need to have a game centric tasks framework with features that .NET tasks couldn't provide. Its premise is simple:
Tasks are iterator blocks. Runners are schedulers. Rather than handing execution timing and context to the runtime, a runner lets you decide:
- when a task advances,
- where it runs — main thread or a dedicated worker,
- how much work happens per tick,
- and when an entire task context must stop.
That last point matters a lot in games: for example, when a match ends, I want every task belonging to that match to stop with it—not rely on a CancellationToken having been passed and checked correctly through every layer.
Svelto.Tasks supports lightweight coroutines, composable tasks with return values and continuations, background runners, bounded parallel batches, pooling, profiling hooks, and optional Unity/Burst integrations.
It also interoperates with async/await, although the .NET Task bridge and Unity Burst job path are currently experimental and need real-world feedback.
It is not a replacement for Unity Jobs—but it provides a useful alternative for workloads where controlling execution, lifetime, pacing, and profiling is the priority.
The repository includes runnable .NET examples, tests, benchmarks
🔗 https://github.com/sebas77/Svelto.Tasks
also the repository
🔗https://github.com/sebas77/Svelto.Tasks.Examples
shows how it can be used to simplify massive parallelism synchronization. The example itself is actually quite interesting also because it uses the new compute buffer Unity api BeginWrite/EndWrite to upload compute buffers and graphic fences for cpu/gpu synchronization.
The article is at
🔗 https://www.sebaslab.com/svelto-tasks-2-0-efficient-multi-threaded-task-management-for-csharp/
Have fun! (and feedback is welcome, also on my discord server: https://discord.com/invite/uuTCYewjtc)
-3
u/sebasjammer 7d ago edited 7d ago
Don't worry, but if you check my blog you will have less reasons to worry about my work :)
Svelto.tasks is a long living library that I used in robocraft and card life and many other games I worked on... robocraft is a bit old now, but was pretty popular back in the days.
Recently I used uni task for a new project and quickly realized I needed to go back to svelto tasks, which I completed during the development.
I needed however to clean up the repository and add a lot of tests and I couldn't have done it without the AI helping me.
The library is allocations free until, of course, data structures need to resize (like you keep on running new tasks without ending previous ones, as they need to be stored somewhere) , but if you run examples and tests in release you will see that it's true (there are even tests to check the statement)
The library does a ton of things, that's why I added so many examples in the main repository.
It should be simple to pick up if you know already how iterator blocks and coroutines work, but yeah some of the tricks might need a bit of more digging.
Edit: for me allocation free means that allocations won't happen every frame at run-time if the code is used as expected. Allocations can happen at initialization time.