public static void ExecuteOrPost(this IMainThread mainThread, Action action, CancellationToken cancellationToken = default(CancellationToken)) { if (mainThread.CheckAccess()) { action(); } else { mainThread.Post(action, cancellationToken); } }
public static void ExecuteOrPost(this IMainThread mainThread, Action action) { if (mainThread.CheckAccess()) { action(); } else { mainThread.Post(action); } }
public Task <IInteractiveWindowVisualComponent> GetOrCreateVisualComponentAsync(int instanceId = 0) { _mainThread.CheckAccess(); if (_visualComponentTcs == null) { _visualComponentTcs = new TaskCompletionSource <IInteractiveWindowVisualComponent>(); CreateVisualComponentAsync(instanceId).DoNotWait(); } else if (instanceId != 0) { // Right now only one instance of interactive window is allowed throw new InvalidOperationException("Right now only one instance of interactive window is allowed"); } return(_visualComponentTcs.Task); }
private void UpdateInfoBarItem(string message) { if (!_mainThread.CheckAccess()) { _mainThread.Post(() => UpdateInfoBarItem(message)); return; } _currentInfoBarItem?.Dispose(); if (message != null) { _viewModel.HasErrors = true; _currentInfoBarItem = _viewModel._infoBar.Add(new InfoBarItem(message, _actions, showCloseButton: false)); } else { _viewModel.HasErrors = false; _currentInfoBarItem = null; } }
public IRPlotDeviceVisualComponent GetOrCreateVisualComponent(IRPlotDeviceVisualComponentContainerFactory visualComponentContainerFactory, int instanceId) { _mainThread.CheckAccess(); IRPlotDeviceVisualComponent component; if (_visualComponents.TryGetValue(instanceId, out component)) { return(component); } component = visualComponentContainerFactory.GetOrCreate(this, _interactiveWorkflow.RSession, instanceId).Component; _disposableBag.Add(component); _visualComponents[instanceId] = component; return(component); }