private void ViewModel_LocatorModeChanged(object sender, EventArgs e)
 {
     _mainThread.Post(() => {
         UpdateCaption();
         UpdateStatus();
     });
 }
Example #2
0
 private void DeviceRemoved(object sender, RPlotDeviceEventArgs e)
 {
     _mainThread.Post(() => {
         RemoveAll(e.Device.DeviceId);
     });
     UnsubscribeDeviceEvents(e.Device);
 }
Example #3
0
 private void DeviceLocatorModeChanged(object sender, RPlotDeviceEventArgs e)
 {
     _mainThread.Post(() => {
         LocatorMode = e.Device.LocatorMode;
         LocatorModeChanged?.Invoke(this, EventArgs.Empty);
     });
 }
Example #4
0
        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);
        }
Example #5
0
 public static void ExecuteOrPost(this IMainThread mainThread, Action action, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (mainThread.CheckAccess())
     {
         action();
     }
     else
     {
         mainThread.Post(action, cancellationToken);
     }
 }
Example #6
0
 public static void ExecuteOrPost(this IMainThread mainThread, Action action)
 {
     if (mainThread.CheckAccess())
     {
         action();
     }
     else
     {
         mainThread.Post(action);
     }
 }
Example #7
0
 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));
     }
 }
Example #8
0
        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));
            });
        }
Example #10
0
        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);
        }
Example #11
0
            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;
                }
            }
Example #12
0
 public void OnCompleted(Action continuation)
 {
     _cancellationToken.ThrowIfCancellationRequested();
     _mainThread.Post(() => continuation());
 }
Example #13
0
 public void OnCompleted(Action continuation)
 {
     Trace.Assert(continuation != null);
     _mainThread.Post(continuation, _cancellationToken);
 }
Example #14
0
 public void OnCompleted(Action continuation) => _mainThread.Post(() => continuation());
 private void OnBrokerChanged(object sender, BrokerStateChangedEventArgs e)
 {
     _mainThread.Post(() => UpdateWindowTitle(e.IsConnected));
 }