[英]Do you think F#'s async workflows will be introduced in C# in the future?
First of all, I apologize because of my foolish question, I really don't know much about F#. 首先,由于我的愚蠢问题,我道歉,我对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?
但是,看到这种语言的构造,有人可能会问为什么C#应该错过异步工作流的凉爽之处? What theoretical limitation does C# have that prevents the aforementioned feature from being introduced?
C#有什么理论上的限制来阻止引入上述功能?
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
). 我不知道您问题的答案,但是关于并发和协调运行时-实际上有更简单的选择(也基于
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). 我很久以前写了一篇关于它的文章,还有Jefrey Richters的“ PowerThreading”库,它出奇的简单和强大(并且使用相同的技巧)。
Asynchronous Programming in C# using Iterators - my article, which shows how to encode F# asynchronous workflows using C# iterators (very directly) 使用迭代器在C#中进行异步编程 -我的文章,展示了如何使用C#迭代器(非常直接)对F#异步工作流进行编码
More AsyncEnumerator Features - discusses how PowerThreading library uses yield return
for asynchronous programming (it uses slightly different programming model, but also very clean and simple, especially compared to CCR). 更多AsyncEnumerator功能 -讨论PowerThreading库如何将
yield return
用于异步编程(它使用略有不同的编程模型,但也非常干净和简单,特别是与CCR相比)。
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. 为了回答这个问题,在技术上是否可以在C#中使用F#异步工作流之类的技术-我会说是-实际上,这是一个与迭代器非常相似的想法(如您所见,您已经可以使用C#迭代器进行异步编程了) !)尽管会有一些有趣的问题要解决。
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. 总是有协调和并发运行时 ,它在C#中提供了类似的样式,但是通过非常规使用
yield
关键字,使代码看起来有些奇怪。 It's proved extremely handy for thread handling in C# and I'd recommend it for anything requiring more than trivial thread coordination. 在C#中证明它非常方便进行线程处理,我建议将它用于需要琐碎的线程协调的任何事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.