tagged [parallel-processing]

what is the relation between Asynchronous and parallel programming in c#?

what is the relation between Asynchronous and parallel programming in c#? I am getting confused as asynchronous programming is a way to execute a block of code asynchronously, that calls a method and ...

15 Sep at 04:16

Parallel Sort Algorithm

Parallel Sort Algorithm I'm looking for a simple implementation of a parallelized (multi-threaded) sort algorithm in C# that can operate on `List` or Arrays, and possibly using Parallel Extensions but...

Wait for QueueUserWorkItem to Complete

Wait for QueueUserWorkItem to Complete If I add jobs to the thread pool with `QueueUserWorkItem`... how do I keep my program from going forward until all jobs are completed? I know I could add some lo...

Is it possible to change parallelOptions.MaxDegreeOfParallelism during execution of a Parallel.ForEach?

Is it possible to change parallelOptions.MaxDegreeOfParallelism during execution of a Parallel.ForEach? I am running a multi-threaded loop: I want to change the `parallelOptions.MaxDegreeOfParallelism

Parallel.ForEach loop with BlockingCollection.GetConsumableEnumerable

Parallel.ForEach loop with BlockingCollection.GetConsumableEnumerable Why `Parallel.ForEach` loop exits with `OperationCancelledException`, while using `GetConsumableEnumerable`? ``` //outside the fun...

Parallel.ForEach() vs. foreach(IEnumerable<T>.AsParallel())

Parallel.ForEach() vs. foreach(IEnumerable.AsParallel()) Erg, I'm trying to find these two methods in the BCL using Reflector, but can't locate them. What's the difference between these two snippets? ...

Why isn't Parallel.ForEach running multiple threads?

Why isn't Parallel.ForEach running multiple threads? Today i tried do some optimization to `foreach` statement, that works on `XDocument`. Before optimization: After optimization: I saw that .

10 Nov at 15:9

Simplest way to run three methods in parallel in C#

Simplest way to run three methods in parallel in C# I have three methods that I call to do some number crunching that are as follows Each of the functions is independent of each other and can be compu...

AsParallel.ForAll vs Parallel.ForEach

AsParallel.ForAll vs Parallel.ForEach Is there any difference between the below code snippets. If so, what? `myList.AsParallel().ForAll(i => { /*DO SOMETHING*/ });` and `Parallel.ForEach(mylist, i => ...

Task.WhenAll result ordering

Task.WhenAll result ordering I understand from [here](http://msdn.microsoft.com/en-us/library/hh556530.aspx) that the task execution order for `Task.Whenall` is not deterministic but I cannot find any...

Track progress when using Parallel.ForEach

Track progress when using Parallel.ForEach I am refactoring my program to use Parallel.ForEach. Before, when I was using a regular for loop, I was updating a WPF progress bar using Dispatcher, display...

6 Oct at 01:29

Under what conditions can TryDequeue and similar System.Collections.Concurrent collection methods fail

Under what conditions can TryDequeue and similar System.Collections.Concurrent collection methods fail I have recently noticed that inside the collection objects contained in [System.Collections.Concu...

How expensive is the lock statement?

How expensive is the lock statement? I've been experimenting with multi threading and parallel processing and I needed a counter to do some basic counting and statistic analysis of the speed of the pr...

Break parallel.foreach?

Break parallel.foreach? [parallel.for](http://msdn.microsoft.com/en-us/library/system.threading.tasks.parallel.for.aspx) I have a pretty complex statement which looks like the following: ``` Parallel....

Check if task is already running before starting new

Check if task is already running before starting new There is a process which is executed in a task. I do not want more than one of these to execute simultaneously. Is this the correct way to check to...

Unit Testing, Deadlocks, and Race Conditions

Unit Testing, Deadlocks, and Race Conditions Any suggestions on how to write repeatable unit tests for code that may be susceptible to deadlocks and race conditions? Right now I'm leaning towards skip...

6 Oct at 23:39

How to wait for a number of threads to complete?

How to wait for a number of threads to complete? What is a way to simply wait for all threaded process to finish? For example, let's say I have: ``` public class DoSomethingInAThread implements Runnab...

What is the difference between concurrent programming and parallel programming?

What is the difference between concurrent programming and parallel programming? What is the difference between concurrent programming and parallel programing? I asked google but didn't find anything t...

Are the ParallelExtensions "Extras" still of value?

Are the ParallelExtensions "Extras" still of value? The [Task Parallels Extras extension](http://blogs.msdn.com/b/pfxteam/archive/2010/04/04/9990342.aspx) was published in 2010, and since then no upda...

How to configure a maximum number of threads in a Parallel.For

How to configure a maximum number of threads in a Parallel.For This is the example microsoft presents for the parallel for, and I'd like to know how configure a maximum number of threads for this code...

10 Apr at 16:51

Optimal number of threads per core

Optimal number of threads per core Let's say I have a 4-core CPU, and I want to run some process in the minimum amount of time. The process is ideally parallelizable, so I can run chunks of it on an i...

20 Jul at 18:46

Observing Task exceptions within a ContinueWith

Observing Task exceptions within a ContinueWith There are various ways in which to observe exceptions thrown within tasks. One of them is in a ContinueWith with OnlyOnFaulted: ``` var task = Task.Fact...

Nested Parallel.ForEach Loops on the same list?

Nested Parallel.ForEach Loops on the same list? I need to parallelize a method that does an exhaustive pairwise comparison on elements in a list. The serial implementation is straight-forward: In this...

Parallel.For(): Update variable outside of loop

Parallel.For(): Update variable outside of loop I'm just looking in to the new .NET 4.0 features. With that, I'm attempting a simple calculation using `Parallel.For` and a normal `for(x;x;x)` loop. H...

What's the best way to update an ObservableCollection from another thread?

What's the best way to update an ObservableCollection from another thread? I am using the `BackgroundWorker` to update an `ObservableCollection` but it gives this error: > "This type of `CollectionVie...