Skip to main content

Posts

Showing posts from March, 2016

Running parallel tasks using ThreadPool.QueueUserWorkItem Method in .NET 3.5

Sometimes we need to run tasks in parallel so that performance of any application can be improved. Here is the sample function to run task in parallel using ThreadPool.QueueUserWorkItem. These parallel task will be added to Queue and as soon as thread is available in thread pool task will be executed. So number of tasks running in parallel depends upon the number of threads available in threadpool. So, in case if system have multiple processors then more threads will be available in threadpool and more tasks can run in parallel. C# Function to run tasks in parallel -             ///   <summary>          ///   Function to  Executes a set of methods or tasks in parallel. The results          ///   from each task or method in an array will be returned when all threads           ///    have completed. No parameter and return value   must not be provided with task or methods          ///   </summary>          ///   <param name="m"></param&g