public IDisposable Subscribe(IObserver <T> observer) { var consumer = SafeObserver <T> .Wrap(observer); // // [OK] Use of unsafe Subscribe: non-pretentious transparent wrapping through remoting; exception coming from the remote object is not re-routed. // var d = _remotableObservable.Subscribe/*Unsafe*/ (new RemotableObserver <T>(consumer)); consumer.SetResource(d); return(d); }
private static void Subscribe_ <T>(this IObservable <T> source, IObserver <T> observer, CancellationToken token) { if (token.CanBeCanceled) { if (!token.IsCancellationRequested) { var consumer = SafeObserver <T> .Wrap(observer); // // [OK] Use of unsafe Subscribe: exception during Subscribe doesn't orphan CancellationTokenRegistration. // var d = source.Subscribe/*Unsafe*/ (consumer); consumer.SetResource(token.Register(state => ((IDisposable)state).Dispose(), d)); } } else { source.Subscribe(observer); } }