C# 클래스 ContinuationExample.MainForm

상속: System.Windows.Forms.Form
파일 보기 프로젝트 열기: drmohundro/presentations

공개 메소드들

메소드 설명
MainForm ( ) : System

보호된 메소드들

메소드 설명
Dispose ( bool disposing ) : void

Clean up any resources being used.

비공개 메소드들

메소드 설명
CalculateRandomNumber ( ) : int

Our really complicated, long running method

DoWorkWithAsync ( ) : Task

Example of using async/await to add threading (non-blocking) to our app. Can you see how these are basically doing the same thing?

DoWorkWithManualContinuations ( ) : IEnumerable

Example of using continuations (with coroutines) to add threading (non-blocking) to our app. Still using yield return, but our caller doesn't just enumerate the results because we don't want to block the UI. However, we're not having to use callbacks here. Why not? See AsyncResult code + the calling code. This ideas was popularized in .NET by the Caliburn library (which Deployer uses).

ExecuteContinuation ( IEnumerator enumerator ) : void

Recursively call continuations... it doesn't care about threads or not

GetRandomNumbers ( int numberOfRandomsToReturn ) : IEnumerable

Example of yield return here... C#'s implementation of coroutines Just syntactic sugar for returning an enumerable... except that it "yields" control to the calling method before going to the next option. And it is up to the caller to ask for the next result. (note the order of writelines) This is lazy evaluation works with LINQ (IQueryable)

GetRandomNumbersAsync ( int numberOfRandomsToReturn ) : Task

Example of using async/await to add threading (non-blocking) to our app. Can you see how these are basically doing the same thing?

GetRandomNumbersContinuation ( int numberOfRandomsToReturn ) : IEnumerable

Example of using continuations (with coroutines) to add threading (non-blocking) to our app. Still using yield return, but our caller doesn't just enumerate the results because we don't want to block the UI. However, we're not having to use callbacks here. Why not? See AsyncResult code + the calling code. This ideas was popularized in .NET by the Caliburn library (which Deployer uses).

InitializeComponent ( ) : void

Required method for Designer support - do not modify the contents of this method with the code editor.

btnDoWorkAsync_Click ( object sender, EventArgs e ) : void

C# does this for us natively now. Awesome.

btnDoWorkContinuation_Click ( object sender, EventArgs e ) : void

This call will NOT block the UI thread.

btnDoWorkNormal_Click ( object sender, EventArgs e ) : void

This call will block the UI thread... it also shows off the C# yield statement

btnNonBlockedUIManual_Click ( object sender, EventArgs e ) : void

메소드 상세

Dispose() 보호된 메소드

Clean up any resources being used.
protected Dispose ( bool disposing ) : void
disposing bool true if managed resources should be disposed; otherwise, false.
리턴 void

MainForm() 공개 메소드

public MainForm ( ) : System
리턴 System