MT Warning : Again, the following text is the product of Machine Translation. I’ll fix it later.
Try it out today and found that 'WebClient' supports asynchronous, but it really does not support concurrent … …
Test code is as follows
Imports System.Net Imports System.Threading Module Module1 Sub Main() Dim c As New WebClient Dim t1 = c.DownloadStringTaskAsync("http://www.baidu.com") Dim t2 = c.DownloadStringTaskAsync("http://www.zhihu.com") Thread.Sleep(10) Console.WriteLine(t1. IsCompleted) Console.WriteLine(t1. IsCompleted) End Sub End Module
Results are as follows
Unhandled exception: System.NotSupportedException:WebClient does not support concurrent I/O operations. In the System.Net.WebClient.ClearWebClientState () At System.Net.WebClient.DownloadStringAsync (Uri address, Object userToken) At System.Net.WebClient.DownloadStringTaskAsync (Uri address) At System.Net.WebClient.DownloadStringTaskAsync (String address) ConsoleApplication1.Module1.Main () ConsoleApplication1Module1.vb: line number 9
Test environment: VS2013.