daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Mar 18th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static int CalculateResult()
  2.         {
  3.             Console.WriteLine("Work Starting");
  4.             Thread.Sleep(2000);
  5.             Console.WriteLine("Work Finished");
  6.             return 99;
  7.         }
  8.         public static void ReturnValue()
  9.         {
  10.             //creating task with return value
  11.             Task<int> task = Task.Run(() =>
  12.             {
  13.                 return CalculateResult();
  14.             });
  15.             //program waits when result property is read
  16.             Console.WriteLine(task.Result);
  17.             Console.WriteLine("Finished Processing. Press a key to end");
  18.             Console.ReadKey();
  19.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top