Skip to content

Instantly share code, notes, and snippets.

private void ExecutingOnANewThread()
{
//both tasks defined bellow will be executed on a new background thread
var task = new Task(() => { }, TaskCreationOptions.LongRunning);
task.Start(TaskScheduler.Default);
//or
var task2 = Task.Factory.StartNew(() => { }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default);
}