using System.Threading.Tasks;
using System.Diagnostics;
static void Main(string[] args)
TaskScheduler scheduler = new ConcurrentExclusiveSchedulerPair(
TaskScheduler.Default, maxConcurrencyLevel: 3).ConcurrentScheduler;
TaskFactory taskFactory = new TaskFactory(scheduler);
Stopwatch stopwatch = Stopwatch.StartNew();
Task[] tasks = Enumerable.Range(1, 12).Select(i => taskFactory.StartNew(async () =>
Console.WriteLine($"Task: {i}, Elapsed: {stopwatch.Elapsed}");