gpt4 book ai didi

.net - 使用线程VB调用Web服务时,发生InvalidOperationException。网

转载 作者:行者123 更新时间:2023-12-03 13:05:13 24 4
gpt4 key购买 nike

我在项目中添加了网络引用。

我正在使用线程,它们以这种方式调用Web服务:

Private Sub principal()
Dim arrayH As New ArrayList
Dim h As Thread
Dim z As Integer = 150

For i As Integer = 1 To Z
h= New Thread(AddressOf doWork)
arrayH.Add(h)
Next


For Each _h As Thread In arrayH
_h.Start()
Next
End Sub

Private Sub doWork()
Dim service As webService.Query
Dim parameter, response As String

parameter = "..."'The parameter is a xml

Try
service = New Query
response = service.Report(parameter)

Catch ex As Exception
'do something
End Try

End Sub

当有许多线程(Z = 150)时,它将引发:
System.InvalidOperationException

There is an error in XML document (1, 279).

Unable to read data from the transport connection: The connection was closed.

在Z小的情况下没有问题。如何避免这种情况?

最佳答案

错误“无法从传输连接读取数据:连接已关闭。”实际上是服务器端的问题。您可能一次要请求太多请求。

关于.net - 使用线程VB调用Web服务时,发生InvalidOperationException。网,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13019135/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com