Questions tagged [parallel-extensions]

Parallel Extensions is a managed concurrency library included in the .NET 4.0 release.

Parallel Extensions is a managed concurrency library included in the .NET 4.0 release. It is composed of two parts: Parallel LINQ (PLINQ) and Task Parallel Library (TPL).

124 questions
11
votes
1 answer

How to get thread Id in C#

public bool HasItemsFromPropertySet(InfoItemPropertySet propertySet, CompositeInfoItem itemRemoved) { var itemAndSubItems = new InfoItemCollection(); if (itemRemoved != null) { …
Recawo
  • 183
  • 1
  • 1
  • 8
9
votes
2 answers

Using Parallel Linq Extensions to union two sequences, how can one yield the fastest results first?

Let's say I have two sequences returning integers 1 to 5. The first returns 1, 2 and 3 very fast, but 4 and 5 take 200ms each. public static IEnumerable FastFirst() { for (int i = 1; i < 6; i++) { if (i > 3) Thread.Sleep(200); …
Alex Norcliffe
  • 2,439
  • 2
  • 17
  • 21
9
votes
1 answer

Parallel.For step size

does anyone know if there's any overload that would allow me to specify a step size in a Parallel.For loop? Samples in either c# or VB.Net would be great. Thanks, Gonzalo
Gonzalo
  • 679
  • 1
  • 8
  • 18
9
votes
2 answers

ConcurrentBag getting duplicates (seems not to be thread safe)

I must be doing something wrong somewhere because i am getting duplicate items in my concurrentbag, here is the chain of events var listings = new ConcurrentBag(); Parallel.ForEach(Types, ParallelOptions, (type, state) => { …
Zoinky
  • 4,083
  • 11
  • 40
  • 78
9
votes
2 answers

Why is the TaskFactory.StartNew method not generic?

The idomatic way to start a new side-effect-only task (that is: a task that returns no result) using the TPL in .NET 4.0 is using the following API: Task Task.Factory.StartNew(Action, object) But why doesn't the signature of this API…
Frank
  • 2,738
  • 19
  • 30
9
votes
1 answer

How can I prevent AppDomainUnloadedException after NUnit tests PLINQ code?

How can I diagnose and minimize or prevent AppDomainUnloadedException? NUnit 2.5.2 consistently throws AppDomainUnloadedException after long (>10s) tests involving PLINQ. Back in July 2008, Stephen Toub said: Yes, the scheduler in the CTP…
Garth Kidd
  • 7,264
  • 5
  • 35
  • 36
8
votes
1 answer

Azure Table Storage Performance from Massively Parallel Threaded Reading

Short version: Can we read from dozens or hundreds of table partitions in a multi-threaded manner to increase performance by orders of magnitude? Long version: We're working on a system that is storing millions of rows in Azure table storage. We…
Jason Young
  • 3,683
  • 4
  • 32
  • 39
8
votes
1 answer

Azure TableQuery thread safety with Parallel.ForEach

I have some basic Azure tables that I've been querying serially: var query = new TableQuery() .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, myPartitionKey)); foreach (DynamicTableEntity…
Paul Lambert
  • 420
  • 3
  • 10
8
votes
4 answers

Using a hashtable inside a Parallel.ForEach?

I have a Parallel.ForEach loop running an intensive operation inside the body. The operation can use a Hashtable to store the values, and can be reused for other consecutive loop items. I add to the Hashtable after the intensive operation is…
Vin
  • 6,115
  • 4
  • 41
  • 55
7
votes
3 answers

Thread-safe buffer of data to make batch inserts of controlled size

I have a simulation that generates data which must be saved to database. ParallelLoopResult res = Parallel.For(0, 1000000, options, (r, state) => { ComplexDataSet cds = GenerateData(r); SaveDataToDatabase(cds); }); The simulation…
7
votes
2 answers

Parallel.For interruption

Suppose you have an array of 1000 random integer numbers and you need to loop over it to find the number 68 for example. Using the new Parallel.For on a quad core CPU would improve speed considerably, making each core to work only 250 array…
abenci
  • 8,422
  • 19
  • 69
  • 134
6
votes
2 answers

TransactionScope not working with Parallel Extensions?

If i do the following: Using scope = New TransactionScope() entries.Content.ReadAs(Of IList(Of WebMaint)).AsParallel.ForAll(Sub(entry) _repos.Update(entry) …
coding4fun
  • 8,038
  • 13
  • 58
  • 85
6
votes
1 answer

Choosing minimum among minima using Parallel.ForEach

I am new to C#, Parallel.ForEach, and .NET in general. I want to parallelize a search that involves thousands of locations. For each location, I compute great circle distance. That is a calculation I want to spread to different cores. My…
gknauth
  • 2,310
  • 2
  • 29
  • 44
6
votes
2 answers

Using Parallel Extensions with ThreadStatic attribute. Could it leak memory?

I'm using Parallel Extensions fairly heavily and I've just now encountered a case where using thread local storage might be sensible to allow re-use of objects by worker threads. As such I was looking at the ThreadStatic attribute which marks a…
redcalx
  • 8,177
  • 4
  • 56
  • 105
5
votes
4 answers

Task Parallel Library - Custom Task Schedulers

I have a requirement to fire off web service requests to an online api and I thought that Parallel Extensions would be a good fit for my needs. The web service in question is designed to be called repeatedly, but has a mechanism that charges you if…
Fen
  • 933
  • 5
  • 13
1
2
3
8 9