I’ve recently had to instrument a piece of code that had to have traits related to both topologically-sorted asynchronous task execution and APM-driven asynchronous execution with PowerThreading's AsyncEnumerator.

Just to illustrate, having a topological sort means you can optimally execute the following task graph:

whereas having APM-driven code via AsyncEnumerator means you can instrument code like this

These two approaches can be merged so that the AsyncEnumerator-driven tasks can be part of a topologically sorted graph. All it takes is replacing the DependencyManager‘s invocation with one involving AsyncEnumerator and forcing the methods to conform to the following signature:

using AsyncMethod = System.Func<Wintellect.Threading.AsyncProgModel.AsyncEnumerator, 
                                System.Collections.Generic.IEnumerator<System.Int32>>;

Get the source code here