Rx (Reactive Programming) was born to solve such problems, try to consider the possibility of changing your environment and replace it with Rx
http://msdn.microsoft.com/en-us/data/gg577609.aspx
Nugget Packages:
https://nuget.org/packages/Rx-Main/1.0.11226
This is the equivalent Rx code:
var o = Observable.Start(() => { throw new NotImplementedException(); }); o.Subscribe( onNext => { }, onError => { }, () => { Console.WriteLine("Operation done"); });
As you can see, the error will not exit the background stream when specifying the error handler, onError => { }
If you do not specify an error handler, an exception will be thrown:
o.Subscribe( onNext => { }, () => { Console.WriteLine("Operation done"); });
In the above example, an exception will be thrown and cause the same problems as your published code
Jupaol
source share