2

プロジェクトに Web 参照を追加しました。

私はスレッドを使用しています。この方法で 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が小さい場合は問題ありません。どうすればこれを回避できますか?

4

1 に答える 1