上一篇讲了这么多,其实说的就是一个事,return会被编译器重写成SetResult,所以如果我们的异步函数返回的是一个Task<int>,代码就要改成这样: using System; using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace StateMachineDemo { class Program { static void Main(string[] args) { Console
C# async await 学习笔记1(http://www.cnblogs.com/siso/p/3691059.html) 提到了ThreadId是一样的,突然想到在WinForm中,非UI线程是无法直接更新UI线程上的控件的问题. 于是做了如下测试: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; us