Since today must systems have multiple processor or cores, slow or blocking applications are less accepted than ever.
On the other hand applications have to handle multiple slow interfaces (network, filesystem, database, http, …), which don’t respond as fast as we would like to.
Over the years this became a challenge in development, working with multiple threads and the GUI in parallel isn’t that easy.
Since C# 5 the async and await keywords are available, which abstract this complex problem.
You call a method which has the async keyword in it’s definition. The call returns immediately, you can alter the GUI or do other stuff in parallel. At the point when you finally need the results, you use the await keyword.
Here’s an example:
The WoisLookup class provides the async methods:
And this is the result:
The full project is available in my Github repository.
MSDN: Asynchronous Programming with Async and Await (C# and Visual Basic)