private async void Button_Click(object sender, RoutedEventArgs e) { if (DownloadedString != null) { FileDownloadingData.FileName = FileName.Text; if (ValidateData()) { FileNameProvider.Invoke(FileDownloadingData.FileName, DownloadedString); } return; } FileDownloadingData.Url = WebsiteUrl.Text; if (ValidateData()) { await Task.Run(async() => { var webClient = new WebClient(); var downloadString = await webClient.DownloadStringTaskAsync(FileDownloadingData.Url); StringDownloaded.Invoke(downloadString); }); } }
private async void Button_Click(object sender, RoutedEventArgs e) { if (DownloadedString != null) { FileNameProvider.Invoke(FileName.Text, DownloadedString); return; } var currentUrl = WebsiteUrl.Text; await Task.Run(async() => { var webClient = new WebClient(); var downloadString = await webClient.DownloadStringTaskAsync(currentUrl); StringDownloaded.Invoke(downloadString); }); }