Created
January 16, 2013 03:22
-
-
Save shiftkey/4544405 to your computer and use it in GitHub Desktop.
Getting started with TPL
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
using System; | |
using System.Diagnostics; | |
using System.Threading.Tasks; | |
namespace PortableClassLibrary1 | |
{ | |
public class Class1 | |
{ | |
public Class1() | |
{ | |
Task.Factory.StartNew(DoSomething); | |
Task.Factory.StartNew(() => DoSomethingReturnTask()) | |
.ContinueWith(t => Debug.WriteLine("This task finished")); | |
} | |
static void DoSomething() | |
{ | |
// something long | |
} | |
static Task DoSomethingReturnTask() | |
{ | |
return Task.Delay(TimeSpan.FromMinutes(1)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment