CSharp Parallel Programming

Last Updated: 3/1/2022

Parallel.Invoke

The Parallel.Invoke method provides a simple way to run any number of arbitrary statements concurrently. Just pass in an Action delegate for each item of work.

Parallel.Invoke(
	BasicAction,
	() => {
		Console.WriteLine("Thread={0}", Thread.CurrentThread.ManagedThreadId);
	},
	delegate()
	{
		Console.WriteLine("Thread={0}", Thread.CurrentThread.ManagedThreadId);
	}
);

Code Sample