Merge branch 'spark_crypto' of bitbucket.org:bluetradesys/spark into spark_crypto

This commit is contained in:
Taha Afzal committed 2022-02-15 13:03:58 -05:00
commit 4c507aae4e
2 files changed
+27 -9

No files matched your search

@@ -22,7 +22,7 @@
public VolSurfaceWindow(
VolSurfaceWindowFactory factory, IBus bus, string vs_name, VolSurfaceWindowSettings startup_data) :
base("Vol Surface", bus, factory, Icons.vol_surface) {
base(vs_name, bus, factory, Icons.vol_surface) {
_startup_data = startup_data ?? throw new ArgumentNullException(nameof(startup_data));
this.vs_name = vs_name;
_dispose = Disposable.Create(() => Disposable.dispose(ref _vm));
@@ -284,32 +284,50 @@ namespace System.Collections.Specialized {
namespace System.Reactive.Linq {
static class SparkObservableExtensions {
// This is placed here to intentionally make ObserveOnDispatcher ambiguous with the one provided by Rx
public static IObservable<T> ObserveOnDispatcher<T>(this IObservable<T> source) {
throw new InvalidOperationException("This method can starve the UI of input messages. Please use OnDispatcher() instead");
}
public static IObservable<T> OnDispatcher<T>(
this IObservable<T> source,
DispatcherPriority priority = DispatcherPriority.Background) =>
source.OnDispatcher(Dispatcher.CurrentDispatcher, priority);
public static IObservable<T> OnDispatcher<T>(
this IObservable<T> source,
Dispatcher dispatcher,
DispatcherPriority priority = DispatcherPriority.Background) {
var dispatcher = Dispatcher.CurrentDispatcher;
if (dispatcher is null) {
throw new ArgumentNullException(nameof(dispatcher));
}
return Observable.Create<T>(o => {
return source.Subscribe(on_next);
async void on_next(T value) {
await dispatcher.check_invoke_async(() => o.OnNext(value), priority);
void on_next(T value) {
if (dispatcher.CheckAccess()) {
o.OnNext(value);
return;
}
dispatcher.InvokeAsync(() => o.OnNext(value), priority);
}
});
}
public static IObservable<T> SubscribeOnDispatcher<T>(
this IObservable<T> source,
DispatcherPriority priority = DispatcherPriority.Background) =>
source.SubscribeOnDispatcher(Dispatcher.CurrentDispatcher, priority);
public static IObservable<T> SubscribeOnDispatcher<T>(
this IObservable<T> source,
Dispatcher dispatcher,
DispatcherPriority priority = DispatcherPriority.Background) {
if (dispatcher is null) {
throw new ArgumentNullException(nameof(dispatcher));
}
return Observable.Create<T>(o => {
object locker = new();
// init sub to a non-null instance, and let 'sub == null' signal
// that the subscription has been disposed
IDisposable sub = Disposable.empty;
Dispatcher.CurrentDispatcher.InvokeAsync(subscribe, priority);
dispatcher.InvokeAsync(subscribe, priority);
return Disposable.Create(dispose);
void subscribe() {