How about you just start your timer with or before your command execution and end it when you get a result or an exception.
If the application is a GUI app then your code will look like this:
Public Class Form1
Dim count As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
count += 1
Label1.Text = count.ToString() & "s"
If count = 10 Then
Timer1.Stop()
End If
End Sub
End Class
You can put the
Timer1.Start()
and the
Timer1.Stop()
anywhere you want, and change the tick event to do whatever you want it to do.
So your code should look like this:
Public Class YourClass
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
Try
Catch ex as exception
Finally
Timer1.Stop()
End Try
End Sub
End Class
Hope it Helps!