/// <summary> /// Handles when an <see cref="LoadingFailedException"/> is thrown while trying to load the lazy content. /// </summary> /// <param name="sender">The lazy content that tried to load.</param> /// <param name="ex">The <see cref="LoadingFailedException"/>.</param> public void HandleLoadException(object sender, LoadingFailedException ex) { // Increment attempt counter if (_attempt < byte.MaxValue) { _attempt++; } // Log const string errmsg = "Failed to load content `{0}` (attempt: {1}). Exception: {2}"; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, sender, _attempt, ex); } // If multiple failures, raise a debug assertion if (_attempt == _attemptsBeforeAssert) { Debug.Fail(string.Format(errmsg, sender, _attempt, ex)); } // Update delay time var now = TickCount.Now; var delay = GetAttemptDelay(_attempt); _nextAttemptTime = now + delay; }
/// <summary> /// Handles when an <see cref="LoadingFailedException"/> is thrown while trying to load the lazy content. /// </summary> /// <param name="sender">The lazy content that tried to load.</param> /// <param name="ex">The <see cref="LoadingFailedException"/>.</param> public void HandleLoadException(object sender, LoadingFailedException ex) { // Increment attempt counter if (_attempt < byte.MaxValue) _attempt++; // Log const string errmsg = "Failed to load content `{0}` (attempt: {1}). Exception: {2}"; if (log.IsErrorEnabled) log.ErrorFormat(errmsg, sender, _attempt, ex); // If multiple failures, raise a debug assertion if (_attempt == _attemptsBeforeAssert) Debug.Fail(string.Format(errmsg, sender, _attempt, ex)); // Update delay time var now = TickCount.Now; var delay = GetAttemptDelay(_attempt); _nextAttemptTime = now + delay; }