Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions xml/System.CodeDom/CodeTypeReference.xml
Original file line number Diff line number Diff line change
Expand Up @@ -555,27 +555,27 @@ System.Collections.Generic.Dictionary`2[[System.String], [System.Collections.Gen

- The <xref:System.CodeDom.CodeTypeReference.BaseType> property for the parent <xref:System.CodeDom.CodeTypeReference> returns the following:

```
```
System.Collections.Generic.Dictionary`2
```
```

- The <xref:System.CodeDom.CodeTypeReference.BaseType> property for the first <xref:System.CodeDom.CodeTypeReference> object in the <xref:System.CodeDom.CodeTypeReference.TypeArguments*> collection returns the following:

```
```
System.String
```
```

- The <xref:System.CodeDom.CodeTypeReference.BaseType> property for the second <xref:System.CodeDom.CodeTypeReference> object in the <xref:System.CodeDom.CodeTypeReference.TypeArguments*> collection returns the following:

```
```
System.Collections.Generic.List`1
```
```

- The <xref:System.CodeDom.CodeTypeReference.TypeArguments> property in the <xref:System.CodeDom.CodeTypeReference> object for ``System.Collections.Generic.List`1`` returns the following:

```
```
System.Int32
```
```

The type argument count should be used when parsing the associated <xref:System.CodeDom.CodeTypeReference.TypeArguments*> values. The common practice is to remove the type argument count from the generated code, but the practice is compiler specific. It is important to note that the type argument count can be found within a nested type name, in which case it is followed by a plus sign ("+").

Expand Down
24 changes: 11 additions & 13 deletions xml/System.Collections.Concurrent/BlockingCollection`1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,33 +85,31 @@
<format type="text/markdown"><![CDATA[

## Remarks
<xref:System.Collections.Concurrent.BlockingCollection`1> is a thread-safe collection class that provides the following:

- An implementation of the producer/consumer pattern; <xref:System.Collections.Concurrent.BlockingCollection`1> is a wrapper for the <xref:System.Collections.Concurrent.IProducerConsumerCollection`1> interface.
<xref:System.Collections.Concurrent.BlockingCollection`1> is a thread-safe collection class that provides the following:

- An implementation of the producer/consumer pattern; <xref:System.Collections.Concurrent.BlockingCollection`1> is a wrapper for the <xref:System.Collections.Concurrent.IProducerConsumerCollection`1> interface.
- Concurrent addition and removal of items from multiple threads with the <xref:System.Collections.Concurrent.BlockingCollection`1.Add*> and <xref:System.Collections.Concurrent.BlockingCollection`1.Take*> methods.

- A bounded collection that blocks <xref:System.Collections.Concurrent.BlockingCollection`1.Add*> and <xref:System.Collections.Concurrent.BlockingCollection`1.Take*> operations when the collection is full or empty.

- Cancellation of <xref:System.Collections.Concurrent.BlockingCollection`1.Add*> or <xref:System.Collections.Concurrent.BlockingCollection`1.Take*> operations by using a <xref:System.Threading.CancellationToken> object in the <xref:System.Collections.Concurrent.BlockingCollection`1.TryAdd*> or <xref:System.Collections.Concurrent.BlockingCollection`1.TryTake*> method.

> [!IMPORTANT]
> This type implements the <xref:System.IDisposable> interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its <xref:System.IDisposable.Dispose*> method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the <xref:System.IDisposable> interface topic. Also, note that the <xref:System.Collections.Concurrent.BlockingCollection`1.Dispose> method is not thread-safe. All other public and protected members of <xref:System.Collections.Concurrent.BlockingCollection`1> are thread-safe and may be used concurrently from multiple threads.
>
> - This type implements the <xref:System.IDisposable> interface. When you've finished using the type, you should dispose of it either directly (by calling its `Dispose` method) or indirectly (with a language construct such as `using` in C#). For more information, see [Use an object that implements IDisposable](xref:System.IDisposable#use-an-object-that-implements-idisposable).
> - The <xref:System.Collections.Concurrent.BlockingCollection`1.Dispose> method is not thread-safe. All other public and protected members of <xref:System.Collections.Concurrent.BlockingCollection`1> are thread-safe and can be used concurrently from multiple threads.

<xref:System.Collections.Concurrent.IProducerConsumerCollection`1> represents a collection that allows for thread-safe adding and removal of data. <xref:System.Collections.Concurrent.BlockingCollection`1> is used as a wrapper for an <xref:System.Collections.Concurrent.IProducerConsumerCollection`1> instance, and allows removal attempts from the collection to block until data is available to be removed. Similarly, you can create a <xref:System.Collections.Concurrent.BlockingCollection`1> to enforce an upper bound on the number of data elements allowed in the <xref:System.Collections.Concurrent.IProducerConsumerCollection`1>; addition attempts to the collection may then block until space is available to store the added items. In this manner, <xref:System.Collections.Concurrent.BlockingCollection`1> is similar to a traditional blocking queue data structure, except that the underlying data storage mechanism is abstracted away as an <xref:System.Collections.Concurrent.IProducerConsumerCollection`1>.
<xref:System.Collections.Concurrent.IProducerConsumerCollection`1> represents a collection that allows for thread-safe adding and removal of data. <xref:System.Collections.Concurrent.BlockingCollection`1> is used as a wrapper for an <xref:System.Collections.Concurrent.IProducerConsumerCollection`1> instance, and allows removal attempts from the collection to block until data is available to be removed. Similarly, you can create a <xref:System.Collections.Concurrent.BlockingCollection`1> to enforce an upper bound on the number of data elements allowed in the <xref:System.Collections.Concurrent.IProducerConsumerCollection`1>; addition attempts to the collection may then block until space is available to store the added items. In this manner, <xref:System.Collections.Concurrent.BlockingCollection`1> is similar to a traditional blocking queue data structure, except that the underlying data storage mechanism is abstracted away as an <xref:System.Collections.Concurrent.IProducerConsumerCollection`1>.

<xref:System.Collections.Concurrent.BlockingCollection`1> supports bounding and blocking. Bounding means that you can set the maximum capacity of the collection. Bounding is important in certain scenarios because it enables you to control the maximum size of the collection in memory, and it prevents the producing threads from moving too far ahead of the consuming threads.Multiple threads or tasks can add items to the collection concurrently, and if the collection reaches its specified maximum capacity, the producing threads will block until an item is removed. Multiple consumers can remove items concurrently, and if the collection becomes empty, the consuming threads will block until a producer adds an item. A producing thread can call the <xref:System.Collections.Concurrent.BlockingCollection`1.CompleteAdding*> method to indicate that no more items will be added. Consumers monitor the <xref:System.Collections.Concurrent.BlockingCollection`1.IsCompleted> property to know when the collection is empty and no more items will be added.
<xref:System.Collections.Concurrent.BlockingCollection`1> supports bounding and blocking. Bounding means that you can set the maximum capacity of the collection. Bounding is important in certain scenarios because it enables you to control the maximum size of the collection in memory, and it prevents the producing threads from moving too far ahead of the consuming threads. Multiple threads or tasks can add items to the collection concurrently, and if the collection reaches its specified maximum capacity, the producing threads will block until an item is removed. Multiple consumers can remove items concurrently, and if the collection becomes empty, the consuming threads will block until a producer adds an item. A producing thread can call the <xref:System.Collections.Concurrent.BlockingCollection`1.CompleteAdding*> method to indicate that no more items will be added. Consumers monitor the <xref:System.Collections.Concurrent.BlockingCollection`1.IsCompleted> property to know when the collection is empty and no more items will be added.

<xref:System.Collections.Concurrent.BlockingCollection`1.Add*> and <xref:System.Collections.Concurrent.BlockingCollection`1.Take*> operations are typically performed in a loop. You can cancel a loop by passing in a <xref:System.Threading.CancellationToken> object to the <xref:System.Collections.Concurrent.BlockingCollection`1.TryAdd*> or <xref:System.Collections.Concurrent.BlockingCollection`1.TryTake*> method, and then checking the value of the token's <xref:System.Threading.CancellationToken.IsCancellationRequested> property on each iteration. If the value is `true`, it is up to you to respond the cancellation request by cleaning up any resources and exiting the loop.
<xref:System.Collections.Concurrent.BlockingCollection`1.Add*> and <xref:System.Collections.Concurrent.BlockingCollection`1.Take*> operations are typically performed in a loop. You can cancel a loop by passing in a <xref:System.Threading.CancellationToken> object to the <xref:System.Collections.Concurrent.BlockingCollection`1.TryAdd*> or <xref:System.Collections.Concurrent.BlockingCollection`1.TryTake*> method, and then checking the value of the token's <xref:System.Threading.CancellationToken.IsCancellationRequested> property on each iteration. If the value is `true`, it is up to you to respond the cancellation request by cleaning up any resources and exiting the loop.

When you create a <xref:System.Collections.Concurrent.BlockingCollection`1> object, you can specify not only the bounded capacity but also the type of collection to use. For example, you could specify a <xref:System.Collections.Concurrent.ConcurrentQueue`1> object for first in, first out (FIFO) behavior, or a <xref:System.Collections.Concurrent.ConcurrentStack`1> object for last in, first out (LIFO) behavior. You can use any collection class that implements the <xref:System.Collections.Concurrent.IProducerConsumerCollection`1> interface. The default collection type for <xref:System.Collections.Concurrent.BlockingCollection`1> is <xref:System.Collections.Concurrent.ConcurrentQueue`1>.
When you create a <xref:System.Collections.Concurrent.BlockingCollection`1> object, you can specify not only the bounded capacity but also the type of collection to use. For example, you could specify a <xref:System.Collections.Concurrent.ConcurrentQueue`1> object for first in, first out (FIFO) behavior, or a <xref:System.Collections.Concurrent.ConcurrentStack`1> object for last in, first out (LIFO) behavior. You can use any collection class that implements the <xref:System.Collections.Concurrent.IProducerConsumerCollection`1> interface. The default collection type for <xref:System.Collections.Concurrent.BlockingCollection`1> is <xref:System.Collections.Concurrent.ConcurrentQueue`1>.

Do not modify the underlying collection directly. Use <xref:System.Collections.Concurrent.BlockingCollection`1> methods to add or remove elements. The <xref:System.Collections.Concurrent.BlockingCollection`1> object can become corrupted if you change the underlying collection directly.
Do not modify the underlying collection directly. Use <xref:System.Collections.Concurrent.BlockingCollection`1> methods to add or remove elements. The <xref:System.Collections.Concurrent.BlockingCollection`1> object can become corrupted if you change the underlying collection directly.

<xref:System.Collections.Concurrent.BlockingCollection`1> was not designed with asynchronous access in mind. If your application requires asynchronous producer/consumer scenarios, consider using <xref:System.Threading.Channels.Channel`1> instead.



## Examples
The following example shows how to add and take items concurrently from a blocking collection:

Expand Down Expand Up @@ -864,7 +862,7 @@
For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose).

> [!NOTE]
> Always call `Dispose` before you release your last reference to the <xref:System.Collections.Concurrent.BlockingCollection`1>. Otherwise, the resources it is using will not be freed until the garbage collector calls the <xref:System.Collections.Concurrent.BlockingCollection`1> object's `Finalize` method.
> Always call `Dispose` before you release your last reference to the <xref:System.Collections.Concurrent.BlockingCollection`1>. Otherwise, the resources it is using will not be freed until the garbage collector calls the <xref:System.Collections.Concurrent.BlockingCollection`1> object's `Finalize` method.

]]></format>
</remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
## Remarks
> [!IMPORTANT]
> This type implements the <xref:System.IDisposable> interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its <xref:System.IDisposable.Dispose*> method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the <xref:System.IDisposable> interface topic.
> This type implements the <xref:System.IDisposable> interface. When you've finished using the type, you should dispose of it either directly (by calling its `Dispose` method) or indirectly (with a language construct such as `using` in C#). For more information, see [Use an object that implements IDisposable](xref:System.IDisposable#use-an-object-that-implements-idisposable).
]]></format>
</remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
## Remarks
> [!IMPORTANT]
> This type implements the <xref:System.IDisposable> interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its <xref:System.IDisposable.Dispose*> method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the <xref:System.IDisposable> interface topic.
> This type implements the <xref:System.IDisposable> interface. When you've finished using the type, you should dispose of it either directly (by calling its `Dispose` method) or indirectly (with a language construct such as `using` in C#). For more information, see [Use an object that implements IDisposable](xref:System.IDisposable#use-an-object-that-implements-idisposable).
]]></format>
</remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
## Remarks

> [!IMPORTANT]
> This type implements the <xref:System.IDisposable> interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its <xref:System.IDisposable.Dispose*> method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the <xref:System.IDisposable> interface topic.
> This type implements the <xref:System.IDisposable> interface. When you've finished using the type, you should dispose of it either directly (by calling its `Dispose` method) or indirectly (with a language construct such as `using` in C#). For more information, see [Use an object that implements IDisposable](xref:System.IDisposable#use-an-object-that-implements-idisposable).

]]></format>
</remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
An <xref:System.ComponentModel.Composition.Hosting.AssemblyCatalog> is used to parse all the parts present in a specified assembly. The target assembly can be indicated either by object reference or by path.
> [!IMPORTANT]
> This type implements the <xref:System.IDisposable> interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its <xref:System.IDisposable.Dispose*> method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the <xref:System.IDisposable> interface topic.
> This type implements the <xref:System.IDisposable> interface. When you've finished using the type, you should dispose of it either directly (by calling its `Dispose` method) or indirectly (with a language construct such as `using` in C#). For more information, see [Use an object that implements IDisposable](xref:System.IDisposable#use-an-object-that-implements-idisposable).
This type is thread safe.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
## Remarks
> [!IMPORTANT]
> This type implements the <xref:System.IDisposable> interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its <xref:System.IDisposable.Dispose*> method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the <xref:System.IDisposable> interface topic.
> This type implements the <xref:System.IDisposable> interface. When you've finished using the type, you should dispose of it either directly (by calling its `Dispose` method) or indirectly (with a language construct such as `using` in C#). For more information, see [Use an object that implements IDisposable](xref:System.IDisposable#use-an-object-that-implements-idisposable).
]]></format>
</remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
## Remarks

> [!IMPORTANT]
> This type implements the <xref:System.IDisposable> interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its <xref:System.IDisposable.Dispose*> method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the <xref:System.IDisposable> interface topic.
> This type implements the <xref:System.IDisposable> interface. When you've finished using the type, you should dispose of it either directly (by calling its `Dispose` method) or indirectly (with a language construct such as `using` in C#). For more information, see [Use an object that implements IDisposable](xref:System.IDisposable#use-an-object-that-implements-idisposable).

]]></format>
</remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
## Remarks
> [!IMPORTANT]
> This type implements the <xref:System.IDisposable> interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its <xref:System.IDisposable.Dispose*> method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the <xref:System.IDisposable> interface topic.
> This type implements the <xref:System.IDisposable> interface. When you've finished using the type, you should dispose of it either directly (by calling its `Dispose` method) or indirectly (with a language construct such as `using` in C#). For more information, see [Use an object that implements IDisposable](xref:System.IDisposable#use-an-object-that-implements-idisposable).
]]></format>
</remarks>
Expand Down
Loading
Loading