Is there something similar to Stackless Python, i.e. a framework that supports continuations, microthreads and lightweight processes in C#? I know that C# 5 is going to support partially some of these features. But is there anything that can be used right now?
3 Answers
Axum is similar, but has been officially dropped as a project from Microsoft:
http://msdn.microsoft.com/en-us/devlabs/dd795202
I've got a blog post showing a basic co-routine at work:
http://adamhouldsworth.blogspot.com/2009/05/microsoft-axum-playtime.html
I have no idea if any of those ideas have been pushed across to the parallel work that went into .NET 4 or the async
stuff slated for C# next.
It can be used right now, and works - but is feature incomplete in some small areas and not supported in a production environment as it's (was?) an incubation project.
Take a look at this on CodeProject (it may address your "lightweight process" requirement):
http://www.codeproject.com/KB/cs/managediocp.aspx
Update: this link describes TPL Data Flow, more primitives added to the .NET framework in order to support agent-based programming. It again might be in the area you are interested in:
http://blogs.msdn.com/b/pfxteam/archive/2010/10/28/10081950.aspx

- 63,413
- 11
- 150
- 187
-
Thanks, seems like what I was looking for, but the fact that it is no longer supported rules it out as an option, unfortunately. – Can Gencer Mar 22 '11 at 16:54
-
Do you know if the builtin ThreadPool makes use of IOCP at all? Or does it dedicate a full thread to every work item? – Can Gencer Mar 22 '11 at 17:03
-
1Fairly certain it is a full thread. I hear nothing but complaints about the standard .NET Thread Pool. There is an alternative to that even, called the Managed Thread Pool offered for free by someone, I forget who. – Adam Houldsworth Mar 22 '11 at 17:08
-
I don't know if this is possible, but could you not integrate Stackless Python into the in .net4? My knowledge is rather vague on this new feature of the framework. Just an idea :) – Stuart Blackler Mar 23 '11 at 11:42
-
Thanks for the latest TPL Data Flow link. seems to be the closest thing to what I am looking for. – Can Gencer Mar 30 '11 at 12:51
-
@Can no problem. I have read the whitepaper and it appears to be built upon the TPL schedulers, which I think use a thread pool or something. Basically, I don't think they are using linked stacks like Stackless or Axum, so it's not quite the same, but close. – Adam Houldsworth Mar 30 '11 at 12:53
My answer to this question may get you started. I use an iterator method (yield return
) to implement a simple coroutine so that a sequence of animations takes place in WPF. The sequence would be able to use any kind of looping, etc. That was really only using C# 2.0 features.

- 1
- 1

- 114,894
- 38
- 205
- 284
You mean something like the parallel extensions PLINQ of the .NET framework?
AFAIK enumerator blocks in C# are much like continuations, but Iam no expert for python.

- 28,510
- 21
- 92
- 151
-
PLINQ is only for making queries parallelized, something like a map and reduce. I was more asking for a more general framework that can handle message passing and scheduling between lightweight processes. – Can Gencer Mar 22 '11 at 16:51