TPL - The Task Parallel Library was designed for parallel programming.
AA - Async and await are for asynchronous programming.
TPL - when you have a lot of work to do and want to split up that work among multiple threads so you can use all the CPU cores.
AA - when you have an operation (or many operations) that will complete in the future, and you want to do other things in the meantime.
TPL - Best suited for CPU-intensive work.
AA - Best suited for I/O-bound work.
There is some overlap. For example, you can treat a parallel computation as an asynchronous operation so it doesn't tie up your UI thread. Also, both the TPL and async/await make use of the
AA - Async and await are for asynchronous programming.
TPL - when you have a lot of work to do and want to split up that work among multiple threads so you can use all the CPU cores.
AA - when you have an operation (or many operations) that will complete in the future, and you want to do other things in the meantime.
TPL - Best suited for CPU-intensive work.
AA - Best suited for I/O-bound work.
There is some overlap. For example, you can treat a parallel computation as an asynchronous operation so it doesn't tie up your UI thread. Also, both the TPL and async/await make use of the
Task type, though they use it in very different ways.
No comments:
Post a Comment