zoukankan      html  css  js  c++  java
  • WebClient does not support concurrent I/O operations 错误的解决办法

    贴出一下自己的出错代码:

    WebClient client = new WebClient();          // 这句话应该放到for循环里.
    for (int i = 0; i < mEmotionUrl.Count; i++)
     {
           string a = mEmotionUrl[i].Url;
           client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
           client.OpenReadAsync(new Uri(a, UriKind.RelativeOrAbsolute));
     }

    最后,google 了半天,并看了许多资料,发现 只要错误信息含有 does not support concurrent I/O operations 信息的,都是由 一个实例同时在多个地方调用产生的,通俗易懂的说,就是并发引起的。下面摘录一句google到得解释:


    I don't think you can use a single WebClient instance to execute several
    HTTP requests at the same time. Try to create a WebClient instance per request,
    that should work just fine.


    原来自己的 client 只有一个实例引发多个调用,就报了上述错误

    解决办法 :每个使用到 WebClient 的地方,都 new 一个 WebClient 实例,防止出现并发。同时 does not support concurrent I/O operations 错误的方法,一般也是由于 并发引起的,解决方法请参照上一句。

  • 相关阅读:
    thusc总结
    5.12总结
    5.9总结
    C语言学习之笔记
    C语言----------指针
    typedef , static和 extern
    数据库(mysql5.5)的一些基本的操作
    Java中基本数据类型占几个字节多少位
    java &和&& 以及 |和 ||之间的异同点
    拨开云雾见月明
  • 原文地址:https://www.cnblogs.com/navigator/p/2917702.html
Copyright © 2011-2022 走看看