c# - Is there any point to using Task Parallel Library -
i have quad core pc.
i had considered programmatically of uterlising multi-core processing using task parallel library. however, when googled examples informed cpu handle automatically , best leave alone.
now, find article singing praises of library on code project.
is there advantage using library?
thanks
unless application actively taking advantage of parallel processing, neither os nor cpu automatically. os , cpu may switch execution of application between multiple cores, not make execute simultaneously on different cores. need make application capable of executing @ least parts in parallel.
according msdn parallel processing , concurrency in .net framework there 3 ways parallel processing in .net:
- managed threading handle threads , synchronization yourself.
- various asynchronous programming patterns.
- parallel programming in .net framework of both
task parallel library,plinqpart.
reasons using tpl include , accompanying tools according msdn article
simplify parallel development can write efficient, fine-grained, , scalable parallel code in natural idiom without having work directly threads or thread pool.
threads vs. tasks has deciding between threads , tpl conclusion:
the bottom line task best option; provides more powerful api , avoids wasting os threads.
the reasons explicitly create own threads in modern code setting per-thread options, or maintaining persistent thread needs maintain own identity.
Comments
Post a Comment