Veikedo

Untitled

Nov 3rd, 2013
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4.  
  5. namespace test1
  6. {
  7.   public class Program
  8.   {
  9.     private static async void SampleAsync()
  10.     {
  11.       Console.WriteLine("SampleAsync start\n");
  12.  
  13.       await Task.Run((Action) LongProccess);
  14.  
  15.       Console.WriteLine("SampleAsync end\n");
  16.     }
  17.  
  18.     private static void LongProccess()
  19.     {
  20.       Console.WriteLine("LongProc start\n");
  21.  
  22.       Thread.Sleep(TimeSpan.FromSeconds(10));
  23.  
  24.       Console.WriteLine("LongProc end\n");
  25.     }
  26.  
  27.     private static void Main()
  28.     {
  29.       Console.WriteLine("Main start\n");
  30.  
  31.       SampleAsync();
  32.  
  33.       Console.WriteLine("Main end\n");
  34.       Console.ReadLine();
  35.     }
  36.   }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment