Async and the UI Thread

An asynchronous method provides a convenient way to do potentially long-running work without blocking the caller’s thread. The caller of an async method can resume its work without waiting for the async method to finish. Asynchrony proves especially valuable for applications that access the UI thread because all UI-related activity usually shares one thread. If any process is blocked in a synchronous application, all are blocked. Your application stops responding, and you might conclude that it has failed when instead it’s just waiting. Asynchrony can be used to prevent this blocking of the UI thread resulting in a much better user experience.

In this short tutorial we look at some underlying concepts (and misconceptions) relating to the use of the Async and Await keywords in VB to implement asynchronous functions. In addition, a small demonstration program is presented and analyzed showing the specific implications of downloading a string of characters from a web service using both a synchronous and an asynchronous function.

Enjoy … bill



Leave a Reply