using System.Threading.Tasks;
static object taskMethodLock = new object();
public static void Main()
var t1 = new Task(TaskMethod, "Run Task");
Task t = Task.Factory.StartNew(() =>
TaskMethod("Run Factory");
static void TaskMethod(object title)
Console.WriteLine(title);
Console.WriteLine("Task id: {0}, thread: {1}",
Task.CurrentId == null ? "no task" : Task.CurrentId.ToString(),
Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("is pooled thread: {0}",
Thread.CurrentThread.IsThreadPoolThread);
Console.WriteLine("is background thread: {0}",
Thread.CurrentThread.IsBackground);