views:

149

answers:

2

First of all, I apologize because of my foolish question, I really don't know much about F#. But I know that it makes thread handling significantly easier. However, seeing the language construct someone might wonder why C# should miss the coolness that is asynchronous workflows? What theoretical limitation does C# have that prevents the aforementioned feature from being introduced?

+1  A: 

There's always the coordination and concurrency runtime which provides a similar style in C#, but makes for some slightly weird looking code via unusual use of the yield keyword. It's proved extremely handy for thread handling in C# and I'd recommend it for anything requiring more than trivial thread coordination.

spender
+4  A: 

I don't know the answer to your question, but regarding Concurrency and Coordination runtime - there are actually simpler alternatives (also based on yield return). I wrote one article about it a long time ago and there is also Jefrey Richters "PowerThreading" library, which is surprisingly simple and powerful (and uses the same trick).

To answer the question whether it would be technically possible to have something like F# asynchronous workflows in C# - I'd say yes - it's actually an idea pretty similar to iterators (and as you can see, you can use C# iterators for asynchronous programming already!) though there would be some interesting problems to resolve.

Tomas Petricek
One word... awesome.
ChaosPandion