using System.Collections.Generic;
using System.Threading.Tasks;
namespace ConsoleApplication1
public static Dictionary<int,int> res = new Dictionary<int,int>(){
static int myFatorFun2(int n)
int temp = myFatorFun2(n - 1) * n;
static Task<int> GetTask(int n){
Task<int> t = Task.Run<int>(()=>{
Console.WriteLine("Task thread is " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine(n + " 计算结果是:" + r);
static async Task<int> GetFactor(int n){
Console.WriteLine("GetFactorStart for : " + n + ". Thread is " + Thread.CurrentThread.ManagedThreadId);
int r = await GetTask(n);
Console.WriteLine("GetFactorEnd for : " + n + ". Thread is " + Thread.CurrentThread.ManagedThreadId);
static void Main(string[] args)
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
int[] a = new int[5] {5,6,7,8,9};
Console.WriteLine("END");