API request WaitingForActivation "Not yet computed" error

This looks like a classic async-await deadlock: you have a SynchronizationContext, you await in it (which means the continuation is scheduled to that SynchronizationContext) and then you block that SynchronizationContext by calling Wait(), which leads to deadlock.

The right solution to not block on async code, your Main should be an async method that returns a Task and awaits balance_task. Another option is to use ConfigureAwait(false) in getLatestWalletAmounts() (and any other "library" method that uses await).


You cannot mix async and synchronous code like this. By calling .Wait, the UI thread is stuck waiting for the task to finish, but the task is essentially trying to "Invoke" on the UI thread, so it cannot finish. Result: deadlock.

You can see more information about the basic problem here.

One option, as a band-aid, is to use ConfigureAwait(false) on the await polo_client.Wallet.GetBalancesAsync() call; that will override the default behavior of trying to return to the UI thread. (Note that means you can't access the UI after the await, because it will be continuing on a different thread!)

I have written a longer piece here about bringing async code into the core of a UI application.

Tags:

C#

Async Await