Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8766069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:27:23+00:00 2026-06-13T16:27:23+00:00

I’m having trouble performing a simple test of the Transient Fault Handling Application Block,

  • 0

I’m having trouble performing a simple test of the Transient Fault Handling Application Block, so I must be missing something silly.

Based on the information in http://msdn.microsoft.com/en-us/library/hh680927(v=pandp.50).aspx and
http://azuretable.blogspot.com/2012/08/unit-testing-transient-errors-in-azure.html I have created the mock class below:

Public Class DBUtils_TestRetryPolicy

' see http://msdn.microsoft.com/en-us/library/hh680927(v=pandp.50).aspx
' see http://azuretable.blogspot.com/2012/08/unit-testing-transient-errors-in-azure.html

Public Class TransientMock
    Implements ITransientErrorDetectionStrategy

    Public Function IsTransient(ex As System.Exception) As Boolean Implements Microsoft.Practices.TransientFaultHandling.ITransientErrorDetectionStrategy.IsTransient
        Return (True)
    End Function
End Class

Private Shared mockExceptionCounter As Integer = 0
Private Shared retryLog As String = ""

Private Sub ThrowException()
    mockExceptionCounter += 1
    Throw New Exception("This is as mock exception to test retries")
End Sub

Public Function TestRetryLogic() As String
    Dim theRetryStrategy = New Incremental(6, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)) ' should result in retries at 0, 1, 3, 5, 7, 9 seconds (25 seconds total)
    theRetryStrategy.FastFirstRetry = True
    Dim theRetryPolicy = New RetryPolicy(Of TransientMock)(theRetryStrategy)
    AddHandler theRetryPolicy.Retrying, AddressOf OnMockConnectionRetry

    mockExceptionCounter = 0
    retryLog = ""

    Try
        theRetryPolicy.ExecuteAction(New System.Action(AddressOf ThrowException))
    Catch ex As Exception
        ' here we should have the last exception thrown after all the retries
        Dim a As Integer = 231234234
    End Try

    Return (retryLog)
End Function

Private Sub OnMockConnectionRetry(sender As Object, e As RetryingEventArgs)
    retryLog += DateTime.UtcNow.ToString + " [" + mockExceptionCounter.ToString() + "] -> CurrentRetryCount [" + Cstr(e.CurrentRetryCount) + "]" + "Delay (ms) [" + CStr(e.Delay.TotalMilliseconds) + "]" + "LastException [" + e.LastException.Message + "]"
End Sub


End Class

All I do in my code is to instantiate this class and call TestRetryLogic().

I ran the Visual Studio debugger expecting to see a few retries, but what I get is a popup from Visual Studio saying “Exception was unhandled by user code”. This happens as soon as I throw inside the method ThrowException(). Of course no retries seem to be happening.

What am I missing?

EDIT: I was failing to cast to string inside OnMockConnectionRetry, so I assume I was throwing an exception inside an (already “running”) exception-handling block. By using the tip from Petar I was able to see (and fix) this little problem and now the retries are working as expected.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:27:24+00:00Added an answer on June 13, 2026 at 4:27 pm

    You need to turn off Common Language Runtime Exceptions by un-checking the User-unhandled option to not get interrupted by VS. This is located under Debug/Exceptions menu.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm making a simple page using Google Maps API 3. My first. One marker
Let's say I'm outputting a post title and in our database, it's Hello Y’all
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.