Asynchronous lambda expressions

Not only methods but also lambda expressions can be async. Among other things this allows event handlers to be anonymous: sumButton.Click += async (sender, e) => { sumButton.IsEnabled = false; await SumPageSizesAsync(GetUrls()); sumButton.IsEnabled = true; }; AddHandler sumButton.Click, Async Function(sender, e) sumButton.IsEnabled = False Await SumPageSizesAsync(GetUrls()) sumButton.IsEnabled = True End Function Another useful application of

Async methods and awaiting in detail

It is important to understand that async methods like SumPageSizesAsync do not run on their own thread. In fact if you write an async method without any await’s in it, it will be completely synchronous: public async Task<int> TenToSevenAsync() { Thread.Sleep(10000); return 7; } Public Async Function TenToSevenAsync() As Task(Of Integer) Thread.Sleep(10000) Return 7 End