I start with TPL and ask about the importance of invoking a method marked async in a call, or just waiting for a calling function that calls a method that is not defined as async.
private async void Button_Click_1(object sender, RoutedEventArgs e) { TBox.Text += await WebClientDownloader(); TBox.Text += await WebClientDownloadWithAwait(); } private async static Task<string> WebClientDownloadWithAwait() { using (var wc = new WebClient()) { return await wc.DownloadStringTaskAsync("http://google.com"); } } private static Task<string> WebClientDownloader() { using (var wc = new WebClient()) { return wc.DownloadStringTaskAsync("http://google.com"); } }
Is there any difference? They seem to perform the same way.
source share