dotnet / dotnet/dotnet-api-docs
https://gist.github.com/sheastrickland/49392be4bb7b2f6b2143
- Lenguaje dominante
- C#
- Estrellas
- 950
- Forks
- 1.7k
- Merge medio
- 2 d 19 h
- PR fusionados (30 d)
- 52
Descripción
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**
Guía de contribución
Línea de trabajo
Comienza con xml/System.Collections.Concurrent/BlockingCollection`1.xml y la página de API vinculada de GetConsumingEnumerable. Añade un ejemplo que documente la combinación de BlockingCollection y Parallel.ForEach, incluida la necesidad de NoBuffering Partitioner mostrada en el issue. Se considera terminado cuando la documentación de la API explica por qué es necesario e incluye el ejemplo funcional.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp
- Área
- documentation
- Tipo de issue
- Documentación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 30/100