Coroutine 協程

https://en.wikipedia.org/wiki/Coroutine

Coroutines are computer program components that generalize subroutines for non-preemptive multitasking, by allowing execution to be suspended and resumed. Coroutines are well-suited for implementing familiar program components such as cooperative tasks, exceptions, event loops, iterators, infinite lists and pipes.php

According to Donald Knuth, Melvin Conway coined the term coroutine in 1958 when he applied it to construction of an assembly program.[1] The first published explanation of the coroutine appeared later, in 1963.[2]ios

協程是計算機程序的一類組件,推廣了協做式多任務子程序,容許執行被掛起與被恢復。相對子例程而言,協程更爲通常和靈活,但在實踐中使用沒有子例程那樣普遍。協程源自SimulaModula-2語言,但也有其餘語言支持。協程更適合於用來實現彼此熟悉的程序組件,如協做式多任務異常處理事件循環迭代器無限列表管道git

根據高德納的說法, 馬爾文·康威於1958年發明了術語coroutine並用於構建彙編程序[1] [2] 協程最初在1963年被提出。[2]github

 

Implementations for C#

  • MindTouch Dream - The MindTouch Dream REST framework provides an implementation of coroutines based on the C# 2.0 iterator pattern
  • Caliburn - The Caliburn screen patterns framework for WPF uses C# 2.0 iterators to ease UI programming, particularly in asynchronous scenarios.
  • Power Threading Library - The Power Threading Library by Jeffrey Richter implements an AsyncEnumerator that provides simplified Asynchronous Programming Model using iterator-based coroutines.
  • The Unity game engine implements coroutines.
  • Servelat Pieces - The Servelat Pieces project by Yevhen Bobrov provides transparent asynchrony for Silverlight WCF services and ability to asynchronously call any synchronous method. The implementation is based on Caliburn's Coroutines iterator and C# iterator blocks.
  • [9] - The .NET 2.0+ Framework now provides semi-coroutine (generator) functionality through the iterator pattern and yield keyword.

C# 5.0 includes await syntax support. 編程

 

Implementing Unity's Coroutines on Winforms and WPF Applications

相關文章
相關標籤/搜索