我想知道使用Fibres和使用新的异步等待和使用Threads有什么优点和缺点.
PS:我们正在使用.Net 4.5
解决方法
I was asking them why they used Fibers and the main developer said
that it’s easier for him to debug. Meaning he knows which thread a
particular function has come from and even could access the variables
higher in the stack.
这听起来很特别.当使用任务并行库与默认ThreadPoolTaskScheduler以外的自定义调度程序时,您可以自己决定如何计划任务(并不一定在新线程上).异步等待另一方面为您提供了一种方便的异步IO方式. VS使您能够使用同步执行的异步代码调试功能.
为了使用光纤,人们必须调用非管理的API,因为.NET不会在BCL中提供任何托管包装器. Even the docs of fibers clearly say there isn’t a clear advantage to using them:
In general,fibers do not provide advantages over a well-designed
multithreaded application. However,using fibers can make it easier to
port applications that were designed to schedule their own threads.
I was wondering what are the advantages and disadvantages of using
Fibers vs using the new async await and using Threads.
使用async-await可以让您在执行IO绑定的异步工作的同时感受到正在执行同步的好处.任务并行库提供了一种简单的方法来调度专用线程的工作,无论是线程池线程还是新线程,同时允许您挂接安排这些工作单元的机制.所有的框架都提供了,我真的看不到使用纤维的优势.
我想你应该告诉你的主要开发人员分别使用Task Parallel Library和async-await对多线程和异步IO工作进行一些阅读.我认为这样会使你们的生活更轻松.