Program.cs 642 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Diagnostics;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. namespace NetCoreTest
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var sw = new Stopwatch();
  12. sw.Start();
  13. var t = SayHello();
  14. Thread.Sleep(4000);
  15. Console.WriteLine(t.Result);
  16. Console.WriteLine(sw.ElapsedMilliseconds);
  17. Console.ReadKey();
  18. }
  19. public static async Task<string> SayHello()
  20. {
  21. Thread.Sleep(5000);
  22. await Task.Delay(5000);
  23. return "hello world";
  24. }
  25. }
  26. }