Deep C# - The Perils of the C# Parallel For |
Written by Mike James | ||||
Sunday, 15 December 2024 | ||||
Page 1 of 3 Making parallel code easier to use is an important development, but making it easier also means you can use it without realising what you are getting into. Unless we can find a way of making parallel code both easy and safe you are still going to have to take care - even with the easy-to-use Parallel For. Find out more in this extract from my book, Deep C#: Dive Into Modern C#. Deep C#Buy Now From Amazon Chapter List
Extra Material <ASIN:1871962714> <ASIN:B09FTLPTP9> So far in our exploration of asynchronous code we have considered parallel execution without necessarily executing anything at the same time. Today’s processors, however, have multiple cores and this means that it is possible to actually run threads in parallel and so hopefully speed things up. Asynchronous code is mostly about keeping the UI responsive by dividing the processor’s attention between servicing the UI and doing useful work. True parallelism has the attraction of speeding up the useful work and thus is attractive even without considering the responsiveness of the UI. The .NET parallel extensions are great. They are easy to use and provide a huge payback – but, and this is a big but, parallel programming isn’t easy. If it was we would be using it all over the place and the parallel extensions would be nothing new. Making parallel code easier to use is an important development, but making it easier also means you can use it without realizing what you are getting into. By being easy to use, |
||||
Last Updated ( Sunday, 15 December 2024 ) |