【问题标题】:visual basic stop webService connectionVisual Basic 停止 webService 连接
【发布时间】:2015-04-15 08:39:41
【问题描述】:

我在visual basic WebService 中的连接代码:

Dim webService As SchnittstelleRechte.Service1 = New SchnittstelleRechte.Service1

如果连接超过 5 秒,我想停止连接。有可能做到这一点???谢谢。

【问题讨论】:

    标签: vb6


    【解决方案1】:

    或者尝试这样做:

    Dim webServiceSchnittstelle As SchnittstelleRechte.Service1
    Dim HttpWReq As HttpWebRequest = CType(WebRequest.Create(Url), HttpWebRequest)
    Dim HttpWResp As HttpWebResponse = CType(HttpWReq.GetResponse(), HttpWebResponse)
    
    If Not IsNothing(HttpWResp) Or Not IsNothing(HttpWResp) Then
        webServiceSchnittstelle = New SchnittstelleRechte.Service1      
    End If
    
    HttpWResp.Close()
    

    【讨论】:

      【解决方案2】:

      尝试这样做:

       Dim webServiceSchnittstelle As SchnittstelleRechte.Service1
       'Dim number as integer = 1
       Public Sub WebServiceConnection()
          'While True
          '  number = number + 1
          'End While
          webServiceSchnittstelle = New SchnittstelleRechte.Service1
       End Sub
      
      
      
       Public Sub angGetSchnittstelle()
         ' Create a thread object
         Dim thread As Thread = New Thread(AddressOf WebServiceConnection)
         ' Start the worker thread
         thread.Start()
         ' Wait 5 seconds on the main thread
         thread.Sleep(5000)
         ' Stop the worker thread
         thread.Abort()
       End Sub
      

      你也可以测试一下,取消注释4行,但是有问题,每次都要等5秒

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多