23.8 Wrap-Up

In this chapter, you learned how to use the async modifier, await operator and Tasks to perform long-running or compute-intensive tasks asynchronously. You learned that tasks that proceed independently of one another are said to execute asynchronously and are referred to as asynchronous tasks.

We showed that multithreading enables threads to execute concurrently with other threads while sharing application-wide resources such as memory and processors. To take full advantage of multicore architecture, we wrote applications that processed tasks asynchronously. You learned that asynchronous programming is a technique for writing apps containing tasks that can execute asynchronously, which can improve app performance and GUI responsiveness in apps with long-running or compute-intensive tasks.

To provide a convincing demonstration of asynchronous programming, we presented several apps:

  • The first showed how to execute a compute-intensive calculation asynchronously in a GUI app so that the GUI remained responsive while the calculation executed.

  • The second app performed two compute-intensive calculations synchronously (sequentially). When that app executed, the GUI froze because the calculations were performed in the GUI thread. The third app executed the same compute-intensive calculations asynchronously. We executed these two apps on single-core and dual-core computers to demonstrate the performance of each program in each scenario.

  • The fourth app used class HttpClient to interact with the Flickr website to search for photos. You learned that class HttpClient is one of many built-in .NET Framework classes that can initiate asynchronous tasks for use with async and await.

  • The last app demonstrated how to show an asynchronous task’s progress in a ProgressBar.

In the online chapters, we begin with an introduction to ASP.NET for building web-based applications in C# and .NET. The ASP.NET chapter is the first of several bonus online chapters. See your book’s inside front cover for information on accessing these via the book’s Companion Website. For a list of the online chapters, visit the book’s web page at


http://www.deitel.com/books/VCSharpHTP6
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset