【问题标题】:Why does calling Async Web Service Method multiple times continuously only executes the method once为什么连续多次调用Async Web Service Method只执行一次方法
【发布时间】:2011-10-20 13:29:09
【问题描述】:

我有一个 Web 服务,我尝试使用异步方法多次调用它。该方法只是记录调用,不会引发异常,也不会返回任何内容。

但是,只有第一个呼叫被记录下来,其余的则不成功。如果是同步调用web方法,或者之前每次都实例化web服务代理,或者减慢调用,调用正常。

不涉及防火墙,没有流量离开机器(我也尝试在另一台机器上托管服务)。

谁能解释为什么只有第一个异步调用成功而其余的没有?另外 - 完成的事件被触发了正确的次数,这很奇怪!我连接了提琴手,只有第一个 Web 服务调用离开了我的机器。

调用代码(只运行一次网络方法):

    Dim svc As New wsLogThisService.LogThisService
    AddHandler svc.LogTestCompleted, AddressOf Completed

    For i As Integer = 1 To 100
        Dim request As New TestRequest
        request.LogLevel = LogLevelOptions.Err
        request.Counter = i.ToString

        svc.LogTestAsync(request)
    Next

调用代码(作品):

    For i As Integer = 1 To 100

        Dim svc As New wsLogThisService.LogThisService
        AddHandler svc.LogTestCompleted, AddressOf Completed

        Dim request As New TestRequest
        request.LogLevel = LogLevelOptions.Err
        request.Counter = i.ToString

        svc.LogTestAsync(request)
    Next

【问题讨论】:

    标签: .net web-services asynchronous


    【解决方案1】:

    找到答案here - 如果您不是每次都实例化服务代理,则需要包含一个状态对象。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      相关资源
      最近更新 更多