dotnet / dotnet/dotnet-api-docs
https://gist.github.com/sheastrickland/49392be4bb7b2f6b2143
- Vorherrschende Sprache
- C#
- Sterne
- 949
- Forks
- 1.7k
- Ø Merge
- 2 T. 19 Std.
- Gemergte PRs (30 T.)
- 52
Beschreibung
The examples do not document one of the most useful combinations, BlockingCollection and Parallel.ForEach.
There is one undocumented requirement for these two constructs to function well together. Both GetConsumingEnumerable and Parallel.ForEach contain chunking logic, which can prevent items from being processed until CompleteAdding is called.
A Partitioner need to be used with NoBuffering.
```
var options = new ParallelOptions { MaxDegreeOfParallelism = 4 };
var partitioner = Partitioner.Create(blockingCollection.GetConsumingEnumerable(), EnumerablePartitionerOptions.NoBuffering);
var results = Parallel.ForEach(partitioner, options, item => { /* PROCESS ITEM*/ });
```
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: f8df56b2-d5da-8d38-ea9d-7f2fb50f877f
* Version Independent ID: f903165e-d4c7-939f-6679-413310730fe6
* Content: [BlockingCollection.GetConsumingEnumerable Method (System.Collections.Concurrent)](https://docs.microsoft.com/en-us/dotnet/api/system.collections.concurrent.blockingcollection-1.getconsumingenumerable?view=netframework-4.7.2#System_Collections_Concurrent_BlockingCollection_1_GetConsumingEnumerable)
* Content Source: [xml/System.Collections.Concurrent/BlockingCollection`1.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Collections.Concurrent/BlockingCollection`1.xml)
* Service: **unspecified**
* Product: **.net**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**
Beitragsleitfaden
Rechercherichtung
Beginne mit xml/System.Collections.Concurrent/BlockingCollection`1.xml und der verknüpften GetConsumingEnumerable-API-Seite. Füge ein Beispiel hinzu, das die Kombination aus BlockingCollection und Parallel.ForEach dokumentiert, einschließlich der im Issue gezeigten Anforderung an die NoBuffering Partitioner. Als erledigt gilt die Aufgabe, wenn die API-Dokumentation erklärt, warum dies erforderlich ist, und das funktionierende Beispiel enthält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 30/100