WebClient does not support concurrency

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

ERROR: si-captcha.php plugin: GD image support not detected in PHP!

Contact your web host and ask them to enable GD image support for PHP.

ERROR: si-captcha.php plugin: imagepng function not detected in PHP!

Contact your web host and ask them to enable imagepng for PHP.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Content is available under CC BY-SA 3.0 unless otherwise noted.