0

Hi I'm Xamarin Developer

I have some Question about using Async Programming

When I Call Webservice, I Usually use async / await.

But In case, It only uses One Thread(UI) so It causes some Problem when UI Change.

For example, Flow the code before getting value and sometimes hang the UI

I Read some Documents or Blogs about Async Programming. That announces that you can solve the problem When using Task.RUN

But it is so hard to know my programming level.....

here is some Example, so could you explain What is different?

notificationVos = await Task.Run(() => wSSmartConsoleCommon.getScMessage<NotificationVo>());

notificationVos = Task.Run(() => wSSmartConsoleCommon.getScMessage<NotificationVo>());

notificationVos = await wSSmartConsoleCommon.getScMessage<NotificationVo>());

notificationVos = await Task.Run(async() => await wSSmartConsoleCommon.getScMessage<NotificationVo>());
  • 1
    Explain the problem a lot more... What does this mean *"But In case, It only uses One Thread(UI) so It causes some Problem when UI Change"* – TheGeneral Dec 23 '20 at 04:23
  • 1
    Related: [await Task.Run vs await](https://stackoverflow.com/questions/38739403/await-task-run-vs-await) – Theodor Zoulias Dec 23 '20 at 09:44
  • 1
    `Task.Run` - creates a new thread, `async/await` - does not. Check out some tutorials by Microsoft: https://www.youtube.com/watch?v=-LY4ATA8Bgw&ab_channel=XamarinDevelopers – Mando Dec 23 '20 at 22:36

0 Answers0