C#程序开发中,使用WebClient实例出现不支持并发I/O操作的异常提示“WebClient does not support concurrent I/O operations ”,解决方法也很简单,使用几个WebClient实例,就new几个WebClient
Stream stream1 = client1.OpenRead(URLAddress); Stream stream2 = client2.OpenRead(URLAddress2);
在上述代码段中出现了两个client实例,一个是client1,一个是client2,为保证两行代码都能正常运行,就需要在代码段前new两个webclient实例
private WebClient client1 = new WebClient(); private WebClient client2 = new WebClient();//创建第二个WebClient实例,解决WebClient不能并发I/O操作问题
百家号 互联网微风说

微信公众号 weisico-com

转载请注明:微思考学习网-关注技术,分享知识 >> webclient不支持并发I/o操作的解决办法