private void ViewModel_LocatorModeChanged(object sender, EventArgs e) { _mainThread.Post(() => { UpdateCaption(); UpdateStatus(); }); }
private void DeviceRemoved(object sender, RPlotDeviceEventArgs e) { _mainThread.Post(() => { RemoveAll(e.Device.DeviceId); }); UnsubscribeDeviceEvents(e.Device); }
private void DeviceLocatorModeChanged(object sender, RPlotDeviceEventArgs e) { _mainThread.Post(() => { LocatorMode = e.Device.LocatorMode; LocatorModeChanged?.Invoke(this, EventArgs.Empty); }); }
private void DoTaskInternal() { Debug.Assert(_taskDoneEvent != null); Action finalAction; if (!IsDisposed) { object result = null; try { result = _taskAction(); } catch (Exception ex) { Debug.Fail(String.Format(CultureInfo.CurrentCulture, "Background task exception: {0}.\nInner exception: {1}\nInner exception callstack: {2}", ex.Message, ex.InnerException != null ? ex.InnerException.Message : "(none)", ex.InnerException != null ? ex.InnerException.StackTrace : "(none)")); result = ex; } finally { finalAction = () => UIThreadCompletedCallback(result); } } else { finalAction = () => UIThreadCanceledCallback(null); } _taskDoneEvent.Set(); _mainThread.Post(finalAction); }
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 static void ShowToolWindow(ToolWindowPane toolWindow, IMainThread mainThread, bool focus, bool immediate) { if (immediate) { mainThread.Assert(); TryShowToolWindow(toolWindow, focus); } else { mainThread.Post(() => TryShowToolWindow(toolWindow, focus)); } }
private void LastActiveTextViewChanged(object sender, ActiveTextViewChangedEventArgs e) { if (ActiveWindow == null) { return; } if (ActiveWindow.TextView.HasAggregateFocus) { _mainThread.Post(Operations.PositionCaretAtPrompt); } }
private void OnHostLoadChanged(object sender, HostLoadChangedEventArgs e) { _mainThread.Post(() => { CpuLoad = e.HostLoad.CpuLoad; MemoryLoad = e.HostLoad.MemoryLoad; NetworkLoad = e.HostLoad.NetworkLoad; Tooltip = string.Format(CultureInfo.InvariantCulture, Resources.HostLoad_Tooltip, (int)Math.Round(100 * CpuLoad), (int)Math.Round(100 * MemoryLoad), (int)Math.Round(100 * NetworkLoad)); }); }
public Task <LocatorResult> StartLocatorModeAsync(Guid deviceId, CancellationToken cancellationToken) { var device = FindDevice(deviceId); device.LocatorMode = true; _locatorTcs = new TaskCompletionSource <LocatorResult>(); _locatorCancelTokenRegistration = cancellationToken.Register(() => CancelLocatorMode(device)); _mainThread.Post(() => { var visualComponent = GetVisualComponentForDevice(deviceId); visualComponent?.Container.Show(focus: false, immediate: true); }, cancellationToken); return(_locatorTcs.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 void OnCompleted(Action continuation) { _cancellationToken.ThrowIfCancellationRequested(); _mainThread.Post(() => continuation()); }
public void OnCompleted(Action continuation) { Trace.Assert(continuation != null); _mainThread.Post(continuation, _cancellationToken); }
public void OnCompleted(Action continuation) => _mainThread.Post(() => continuation());
private void OnBrokerChanged(object sender, BrokerStateChangedEventArgs e) { _mainThread.Post(() => UpdateWindowTitle(e.IsConnected)); }