This is a C#.NET exclusive community
//C#
using System.Threading.Tasks;
void f(int arg)
{
//...
}
void main()
{
var options = new ParallelOptions() { MaxDegreeOfParallelism = 8 } ;
Parallel.For(1, 1000_000, options, f) ;
}
//C#
using System.Threading.Tasks;
void f(int arg)
{
//...
}
void main()
{
var options = new ParallelOptions() { MaxDegreeOfParallelism = 8 } ;
var values = new int [ ] { 123, 456, 789, 147, 258, 369 /* ...array-items... */ } ;
Parallel.ForEach(values, options, f) ;
//the 'values' is a IEnumerable, which means a stream of data of specified/unknown length. ex. array,list,linkedList,queue,stack,dbCursor,...
}