3 ms·
Can use System.Threading.Channels https://docs.microsoft.com/en-us/dotnet/api/system.threading.channels?view=dotnet-plat-ext-2.1 https://docs.microsoft.com/en-u
by benaadams 8y ago
Can use System.Threading.Channels
https://docs.microsoft.com/en-us/dotnet/api/system.threading.channels?view=dotnet-plat-ext-2.1 https://docs.microsoft.com/en-us/dotnet/api/system.threading... if you like that programming model
- coder543 8y agoDo those channels support async? Since C# is built around async/await for scaling to large numbers of connections / tasks, they wouldn't be very useful if they didn't support async, but I'm not familiar enough with modern C# to figure out if they do or not.
- manigandham 8y agoYes. It's a library that is fully async. We process millions of records/second using these.
- noir_lord 8y agoDo you happen to have any public information on this approach, it sounds interesting but I'm not up on the C# world like I used to be.
- manigandham 8y agoThis is the best overview article so far: https://ndportmann.com/system-threading-channels/ https://ndportmann.com/system-threading-channels/
- noir_lord 8y agoThank you.
- benaadams 8y agoYeah you have a triple for different use cases; the sync call is `TryRead` so its non-blocking; `ReadAsync` for async reading and `WaitToReadAsync` to wait for data to be available without reading (likely then followed by the non-blocking `TryRead` in usage)
- tapirl 8y agoDoes it support select? Almost half of concurrrent programming use cases in Go are select related.
- benaadams 8y agoYeah, at a guess you'd combine the multiple `WaitToReadAsync` with `await Task.WhenAny`; then use `TryRead` to run though the bunch of channels in a non-blocking way. Could even use the return `await Task.WhenAny` to tell you the specific one to check. Shouldn't be a very hard construct to make; to make it more select like.
- tapirl 8y agogood. It looks it is much like the reflect.Select (https://golang.org/pkg/reflect/#Select https://golang.org/pkg/reflect/#Select) in Go. It has the benefit that any number of tasks can be selected, but the efficiency is not good as hard-coded select blocks. But it looks C# Task.WhenAny has much less use case variants than Go select block.