Is there a fiber api in .net?

冷暖自知 提交于 2019-12-17 12:24:25

问题


Out of more curiosity than anything I've been looking for a set of C#/.net classes to support fibers/co-routines (the win32 version) and haven't had any luck.

Does anybody know of such a beast?


回答1:


Have you seen this:

Title "Implementing Coroutines for .NET by Wrapping the Unmanaged Fiber API"
in the September 2003 issue of MSDN Magazine

http://msdn.microsoft.com/en-us/magazine/cc164086.aspx




回答2:


No. There isn't a Fiber API in the Framework. I suspect this is because there is little advantage to using them - even the fiber API page (native) mentions:

In general, fibers do not provide advantages over a well-designed multithreaded application.

.NET makes it so much easier to develop a "well-designed" multithreaded application that I suspect there is little use for a fiber API.




回答3:


If I remember correctly, there was one in the .NET 2 beta, but it was dropped. Eric Lippert wrote about fibers and continuations and said they chose the smallest necessary (link).

There are ways to use iterators and yield to make a coroutine system, see this link. And another one from Joe Duffy.



来源:https://stackoverflow.com/questions/1949051/is-there-a-fiber-api-in-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!