Where do I mark a lambda expression async?

I’ve got this code: private async void ContextMenuForGroupRightTapped(object sender, RightTappedRoutedEventArgs args) { CheckBox ckbx = null; if (sender is CheckBox) { ckbx = sender as CheckBox; } if (null == ckbx) { return; } string groupName = ckbx.Content.ToString(); var contextMenu = new PopupMenu(); // Add a command to edit the current Group contextMenu.Commands.Add(new UICommand(“Edit this … Read more

Async/Await Class Constructor

At the moment, I’m attempting to use async/await within a class constructor function. This is so that I can get a custom e-mail tag for an Electron project I’m working on. customElements.define(‘e-mail’, class extends HTMLElement { async constructor() { super() let uid = this.getAttribute(‘data-uid’) let message = await grabUID(uid) const shadowRoot = this.attachShadow({mode: ‘open’}) shadowRoot.innerHTML … Read more

Catch an exception thrown by an async void method

Using the async CTP from Microsoft for .NET, is it possible to catch an exception thrown by an async method in the calling method? public async void Foo() { var x = await DoSomethingAsync(); /* Handle the result, but sometimes an exception might be thrown. For example, DoSomethingAsync gets data from the network and the … Read more

If async-await doesn’t create any additional threads, then how does it make applications responsive?

Time and time again, I see it said that using async–await doesn’t create any additional threads. That doesn’t make sense because the only ways that a computer can appear to be doing more than 1 thing at a time is Actually doing more than 1 thing at a time (executing in parallel, making use of … Read more

Running multiple async tasks and waiting for them all to complete

I need to run multiple async tasks in a console application, and wait for them all to complete before further processing. There’s many articles out there, but I seem to get more confused the more I read. I’ve read and understand the basic principles of the Task library, but I’m clearly missing a link somewhere. … Read more

HttpClient.GetAsync(…) never returns when using await/async

Edit: This question looks like it might be the same problem, but has no responses… Edit: In test case 5 the task appears to be stuck in WaitingForActivation state. I’ve encountered some odd behaviour using the System.Net.Http.HttpClient in .NET 4.5 – where “awaiting” the result of a call to (e.g.) httpClient.GetAsync(…) will never return. This … Read more