visual basic 停止 webService 连接
visual basic stop webService connection
我在 visual basic WebService 连接代码中有:
Dim webService As SchnittstelleRechte.Service1 = New SchnittstelleRechte.Service1
如果超过 5 秒,我想停止此连接。有可能做到这一点???谢谢。
尝试这样做:
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秒
或尝试这样做:
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()
我在 visual basic WebService 连接代码中有:
Dim webService As SchnittstelleRechte.Service1 = New SchnittstelleRechte.Service1
如果超过 5 秒,我想停止此连接。有可能做到这一点???谢谢。
尝试这样做:
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秒
或尝试这样做:
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()