Working with Channels in .NET

preview_player
Показать описание
Channels enable a producer to safely pass data over to a consumer along with the appropriate notifications in both directions.

In this episode, Stephen Toub chats with Rich about the what, why and how of using the System.Threadding.Channels library. They walk us through a simple demo of using channels and also discuss the various strategies at our disposal.

[00:55] - What are channels used for?
[01:35] - Creating a basic channel implementation
[09:15] - Moving to System.Threadding.Channels
[11:34] - What are the benefits of using the System.Threadding.Channels?
[14:11] - What are some of the available back pressure strategies?
[20:58] - Working with varying number of producers or consumers
[21:54] - What are the merits of Channels compared to Pipelines?
[23:35] - Can channels be used out of process scenarios?
[24:30] - Can channels be used with pub/sub
[25:28] - What’s next for channels?

An introduction to System.Threading.Channels

System.Threading.Channels NuGet package

System.Threadding.Channels on GitHub

#dotnet #channel #concurrency #runtime
Рекомендации по теме
Комментарии
Автор

Learning is always so easy with Stephen Toub

draganradovac
Автор

Nice format, very informative.
Thanks for showing the code, I was able to put it in Visual Studio and try it out.
Great way to learn.

dune
Автор

Good job men. This piece of infrastructure was desperately needed!

imensonspionrona
Автор

Very informative way to demonstrate the idea.

EzDoesntExist
Автор

Guys, thanks for this! Informative, useful, clear. I'm pumped for all of the performance improvements things.

sergeymikolaitis
Автор

Great discussion! Liked the comparisons to pipelines and pub/sub. Surprised, however, there was no comparison to all the Rx stuff.

dcuccia
Автор

I never knew the lead singer to Metallica had a coding channel

letgabeequaltrue
Автор

Awesome, thanks I was reading about this last week

johnnm
Автор

What I don't feel you addressed was, what is this for? What are the concrete use-cases for this mechanism? Might be a topic for a follow-up episode.

RasmusSchultz
Автор

So I have c# like Notebook app and run workflows in the background. There are several ways of displaying information and would like to know what tech. would work best: Channel, Pipeline, other?
1. Showing progress (ok to lose frames of data)
2. Logging results to a file (frames of data cannot be missed)
3. Logging results to a view (frames of data cannot be missed)

I tried using ShareMemory for the progress and reading just last value when possible, but takes a bit to setup.

AdamsTaiwan
Автор

Good enough information to getting started but Is there a way i can connect two different services using a separate channel service and how can i migrate this in memory operation to a persistent data store for fault tolerant

MrRishabSharma
Автор

Great (high quality) learning content guys! It helped me a lot. Hope it does others as well. 👍🏼🙂

NavedRasul
Автор

[21:54] - What are the merits of Channels compared to Pipelines?

ivandrofly
Автор

10:19 - bound vs unbound writing
21:50 - comparison with Pipelines

ivandrofly
Автор

Since Channel.CreateUnbounded<T> has a set number and capacity, is this useful in a scenario like a database record for example say you store a serialized JSON per record in the filesystem and want to avoid race conditions in a high concurrency scenario where clients may be reading from the same table at the same time, but you don't want them to read a record that's in the middle of being written so you need to implement record locking, and there could be multiple records queued up to be written at a time from different clients?

johnernest
Автор

channel like blockingCollection, so what is diff ?

jianglongdu
Автор

10:54 You're not the only one. 😂😂😂

conaxlearn
Автор

Great feature! I have code to refactor!

christopherhill
Автор

Reactive extensions is much more powerful as it is much higher in abstraction, but this has better backpressure semantics, as this is a low-level construct

srivathsaharishvenk
Автор

You need to add read based on value condition

yasser