Control event TimeOut in VB.NET

1

I am doing a query towards a webservice with VB.NET which will return me if the mail was successfully validated or if the email is invalid. When you send it to call it stays like this:

Public Shared Function verificaremail(ByVal email As String) As String
    Try
        Dim siService As StrikeIron.EMV6Hygiene = New StrikeIron.EMV6Hygiene()
        Dim timeout As Integer = 30
        Dim OptionalSourceID = " "
        siService.VerifyEmail(email.Trim(), timeout, OptionalSourceID)
        return true
    Catch tex As TimeoutException
        return True
    Catch ex As Exception
        return False
    End Try
End Function

My question is: How can I handle the exception when the 30 seconds of the consultation have passed?

Since I am currently taking it as "ex" and it is returning false when doing tests.

I have omitted the steps for authentication since it is irrelevant to the process, and I do not receive an error from that part.

    
asked by cport93 26.05.2017 в 18:32
source

1 answer

1

Good, you can try to capture the generic exception and inside look at what type it is in particular with the GetType () method:

Try
    Dim siService As StrikeIron.EMV6Hygiene = New StrikeIron.EMV6Hygiene()
    Dim timeout As Integer = 30
    Dim OptionalSourceID = " "
    siService.VerifyEmail(email.Trim(), timeout, OptionalSourceID)
    return true

Catch ex As Exception
    If ex.GetType() = Type.GetType("System.TimeoutException") Then
        return True
    Else
        return False
    End If
End Try

Greetings.

    
answered by 28.07.2017 / 13:43
source