public static IDisposable SubscribeDisposableRender <T>(this IObservableExceptional <T> o, Func <T, IDisposable> fn, IModelDoc2 doc, Action <Exception> errHandler) { var d = new SerialDisposable(); var s = o .ObserveOnSolidworksThread() .Subscribe(onNext: v => { using (OpenGlRenderer.DeferRedraw(doc)) { try { d.Disposable = Disposable.Empty; d.Disposable = fn(v) ?? Disposable.Empty; } catch (Exception e) { d.Disposable = Disposable.Empty; errHandler(e); } } }, onError: e => { d.Disposable = Disposable.Empty; errHandler(e); }); return(new CompositeDisposable(s, d)); }
public static IDisposable DisplayUndoable (this IEnumerable <IRenderer> renderable, IModelDoc2 doc, int layer = 0) { return(OpenGlRenderer.DeferRedraw (doc , () => renderable.Select(r => r.DisplayUndoable(doc, layer)).ToCompositeDisposable() )); }