async-await C# with Example
using System; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace CSharpMultiThreading { class MyClass { public int Get10() // Func compatible { return 10; } public async Task DoWorkAsync() { Func ten = new Func(Get10); int a = await Task.Run(ten); int b = await Task.Run(new Func(Get10)); int c = await Task.Run(() => { return 10; }); Console.WriteLine("{0} {1} {2}", a, b, c); } } class Program { static void Main() { Task t = (new MyClass()).DoWorkAsync(); t.Wait(); } } }