, , . @0xA3.
"", , :
Sub TryExecute(Of T As Exception)(ByVal nofTries As Integer,
ByVal anAction As Action)
For i As Integer = 1 To nofTries - 1
Try
anAction()
Return
Catch ex As T
Thread.Sleep(2000)
End Try
Next
' try one more time, throw if it fails
anAction()
End Sub
:
TryExecute(Of SomeExceptionType)(3, Sub()
<Block>
End Sub())
VB 10, .Net 3.5/VB 9,