Skip to content

Instantly share code, notes, and snippets.

@luisdeol
Last active November 12, 2017 14:08
Show Gist options
  • Save luisdeol/e427c7b69d9ba9bbb0db4b011cef9948 to your computer and use it in GitHub Desktop.
Save luisdeol/e427c7b69d9ba9bbb0db4b011cef9948 to your computer and use it in GitHub Desktop.
Using Tasks
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