I'm working on a project, there we need to implement multi tasking for some functionality. For this we have used .NET's one of the great API - Task Parallel Library (TPL).
Eg. code for TPL (taken from here)
static void Main()
{
var options = new ParallelOptions()
{
MaxDegreeOfParallelism = 2
};
List<int> integerList = Enumerable.Range(0,10).ToList();
Parallel.ForEach(integerList, options, i =>
{
Console.WriteLine(@"value of i = {0}, thread = {1}",
i, Thread.CurrentThread.ManagedThreadId);
});
Console.WriteLine("Press any key to exist");
Console.ReadLine();
}
As we know, we can use 'MaxDegreeOfParallelism' option to set maximum threads to be used.
Suppose we have 16 virtual core VM, I want to run application that should target only few selected cores say C1, C2, c8, c9.
Please guide me how it can be done using TPL?
Thanks, Vijay