Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DownloadStringAsync has return type void. So how do I await it?

Looking at the documentation here https://msdn.microsoft.com/en-us/library/ms144202(v=vs.110).aspx, DownloadStringAsync has return type void, which means VS gives me an error

Cannot await 'void'

So how am I supposed to use that method?

like image 906
user7127000 Avatar asked Mar 13 '17 05:03

user7127000


1 Answers

Use DownloadStringTaskAsync which supports the async/await pattern

public Task<string> DownloadStringTaskAsync(Uri address)

like image 80
Itsik Avatar answered Nov 01 '22 23:11

Itsik