4 ms·
In the past few years C# updates and new .net libraries have had a sort of concurrency and parallelism focus. The Task Parallel Library (TPL)[1] is basically l
by usea 14y ago
In the past few years C# updates and new .net libraries have had a sort of concurrency and parallelism focus.
The Task Parallel Library (TPL)[1] is basically like goroutines in Go. They're a concurrency construct, for executing code that gets multiplexed to threads via the thread pool by default. Absurdly useful and very easy to use. This contains stuff like Task, Parallel.ForEach, .ContinueWith() etc.
The TPL Dataflow[2] stuff added just recently is data pipelining. Completely thread-safe communication of data, with the ability to construct a complex data pipeline that your data gets pushed through. Similar to channels in Go.
Also added recently are the async and await keywords[3] in C# and VB.NET. These are compiler features that allow you to write asynchronous code exactly the same way as you would write synchronous code. Basically a replacement for the IAsyncResult + BeginFoo/EndFoo pattern, it allows you to write simple and readable asynchronous code. Not necessarily multi-threaded as it can be used with single-threaded code, but it allows the stuff that interacts with your multi-threaded code to not bend over backwards for it.
[1] http://msdn.microsoft.com/en-us/library/dd460717.aspx http://msdn.microsoft.com/en-us/library/dd460717.aspx
[2] http://msdn.microsoft.com/en-us/devlabs/gg585582.aspx http://msdn.microsoft.com/en-us/devlabs/gg585582.aspx
[3] http://msdn.microsoft.com/en-us/library/hh191443.aspx http://msdn.microsoft.com/en-us/library/hh191443.aspx
- upthedale 14y agoDon't forget Rx [1] It enhances support for the IObservable/IObserver interfaces, the duals of IEnumerable/IEnumerator, allowing Linq manipulation of asynchronous events. As others have discussed or at least alluded to, C# certainly started out on a par with Java, but has grown into a different beast altogether, if one makes use of all the new developments mentioned. These days my C# code is very un-Java-like, and far more Functional. [1] http://msdn.microsoft.com/en-us/data/gg577609.aspx http://msdn.microsoft.com/en-us/data/gg577609.aspx