3

I want to resume a sequence only under certain condition.

I have this Observable:

Observable
    .Defer(() => Observable.FromAsync(SomeAsync))
    .Retry();

The condition: The observable should retry only when it receives an CustomException with a specific ResultCode.

Then, I've thought about this:

Observable
    .Defer(() => Observable.FromAsync(SomeAsync))
    .Catch<T, CustomException>(exception => ShouldRetry(exception) ? ____ : Observable.Throw<T>(exception));

But, I don't know what to put in the ____ part, when the Observable should retry itself. It seems like the definition contains the concept to be defined, something recursive.

How do I make this conditional retry?

TheLethalCoder
  • 6,668
  • 6
  • 34
  • 69
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
  • 4
    Isn't [this](http://stackoverflow.com/questions/18978523/write-an-rx-retryafter-extension-method) what you're after? `Observable.Defer(() => Observable.FromAsync(SomeAsync)) .RetryWithBackoffStrategy( retryCount: 4, retryOnError: e => e is CustomException && e.ResultCode == 'my magic number' )` – Michael Nov 17 '16 at 10:27

0 Answers0