Last active
November 12, 2017 14:08
-
-
Save luisdeol/e427c7b69d9ba9bbb0db4b011cef9948 to your computer and use it in GitHub Desktop.
Using Tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MultiThreadingExamples | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Task thePowerfulTask = Task.Run(() => | |
{ | |
for (var i = 0; i < 1000; i++) | |
{ | |
Console.Write("for Execution nº: "+i+", "); | |
} | |
}); | |
thePowerfulTask.Wait(); | |
Task<string> thePowerfulTaskWithReturn = Task.Run(() => "sleepy!"); | |
Console.WriteLine("Luis is " + thePowerfulTaskWithReturn.Result); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment