Skip to content

Reorganize channels.md: show basics before bounding strategies, add multiple readers/writers example#52334

Open
Copilot wants to merge 10 commits intomainfrom
copilot/fix-badly-organised-content
Open

Reorganize channels.md: show basics before bounding strategies, add multiple readers/writers example#52334
Copilot wants to merge 10 commits intomainfrom
copilot/fix-badly-organised-content

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

The System.Threading.Channels article introduced bounding strategies before covering the producer/consumer APIs, and had no end-to-end example of concurrent multiple producers and consumers.

Changes

  • Reordered sections: Producer APIs → Consumer APIs → Common usage patterns now precede Bounding strategies, so readers encounter the operational API before configuration details.
  • New section: "Multiple producers and consumers" under Common usage patterns, with a complete example showing 3 concurrent producers and 2 concurrent consumers sharing a single channel.
  • New snippet: Program.MultipleReadersWriters.cs — fan-out/fan-in pattern using Task.WhenAll, ReadAllAsync, and a single Writer.Complete() after all producers finish.
Channel<Coordinates> channel = Channel.CreateUnbounded<Coordinates>(
    new UnboundedChannelOptions { SingleWriter = false, SingleReader = false });

Task[] producerTasks = Enumerable.Range(0, 3).Select(id => Task.Run(async () =>
{
    // each producer writes a unique coordinate series
    await channel.Writer.WriteAsync(/* ... */);
})).ToArray();

Task[] consumerTasks = Enumerable.Range(0, 2).Select(_ => Task.Run(async () =>
{
    await foreach (var coordinates in channel.Reader.ReadAllAsync())
        Console.WriteLine(coordinates);
})).ToArray();

await Task.WhenAll(producerTasks);
channel.Writer.Complete();          // signal only after ALL producers are done
await Task.WhenAll(consumerTasks);
Original prompt

This section details on the original issue you should resolve

<issue_title>Badly organised</issue_title>
<issue_description>### Type of issue

Other (describe below)

Description

You start with bounding strategies before showing the basics of operation. Then you don't show any example of a multiple reader/writer.

Page URL

https://learn.microsoft.com/en-us/dotnet/core/extensions/channels

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/extensions/channels.md

Document Version Independent Id

73e99a1a-078d-c96b-9d05-7c47acaf7fb4

Article author

@IEvangelist

Metadata

  • ID: e9152c35-17b4-bbf2-7ec9-3e867c0a48aa
  • Service: dotnet-fundamentals

Related Issues


Associated WorkItem - 558445</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Internal previews

📄 File 🔗 Preview link
docs/core/extensions/channels.md System.Threading.Channels library

…ultiple readers/writers example

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix badly organised content in channels documentation Reorganize channels.md: show basics before bounding strategies, add multiple readers/writers example Mar 17, 2026
Copilot AI requested a review from gewarren March 17, 2026 23:03
@gewarren gewarren marked this pull request as ready for review March 18, 2026 01:31
@gewarren gewarren requested a review from a team as a code owner March 18, 2026 01:31
Copilot AI review requested due to automatic review settings March 18, 2026 01:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the System.Threading.Channels documentation to improve learning flow and adds a new end-to-end example demonstrating concurrent multiple producers and consumers sharing a single channel.

Changes:

  • Added a new “Basic usage” section with a simple producer/consumer example.
  • Added a new “Multiple producers and consumers” section and a corresponding snippet demonstrating fan-out/fan-in over a single channel.
  • Updated/normalized several xref links and some wording in the article.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
docs/core/extensions/channels.md Adds “Basic usage”, adds multi-producer/multi-consumer section, and adjusts section structure/xrefs.
docs/core/extensions/snippets/channels/Program.MultipleReadersWriters.cs New snippet that demonstrates 3 producers and 2 consumers using an unbounded channel with multi-reader/writer options.

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot AI requested a review from gewarren March 18, 2026 23:19
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Badly organised

3 participants