My Async Causes Deadlock On UI - What is the best way to not cause deadlock?

zzinzzin CAMember ✭✭

string bal;
bal = await Task.Run(()=> GetBalanceAsync(uzer)); <--- better way to await to not cause deadlock?
if (bal == "Issue")
{
}
else
{
banklabel.Text = "$: " + Convert.ToDecimal(bal).ToString("#,##0.00");
}

Answers

  • JohnHardmanJohnHardman GBUniversity mod

    @zzin - It depends on what happens inside GetBalanceAsync. Assuming it is has been written in what I would consider the standard way, try:

        bal = await GetBalanceAsync(uzer);
    
Sign In or Register to comment.