Invoke() public static method

Executes an action on the UI thread. If this method is called from the UI thread, the action is executed immendiately. If the method is called from another thread, the action will be enqueued on the UI thread's dispatcher and executed asynchronously.

For additional operations on the UI thread, you can get a reference to the UI thread's context thanks to the property UiContext

.
public static Invoke ( System.Action action ) : void
action System.Action The action that will be executed on the UI /// thread.
return void
Ejemplo n.º 1
0
        public void SetStatusText(string value = null)
        {
            var text = value ?? RubberduckUI.ResourceManager.GetString("ParserState_" + _state.Status);

            _logger.Debug("RubberduckCommandBar status text changes to '{0}'.", text);
            UiDispatcher.Invoke(() => _statusButton.Caption = text);
        }
Ejemplo n.º 2
0
        public void SetSelectionText(Declaration declaration)
        {
            if (declaration == null && _vbe.ActiveCodePane != null)
            {
                var selection = _vbe.ActiveCodePane.GetQualifiedSelection();
                if (selection.HasValue)
                {
                    SetSelectionText(selection.Value);
                }
                _selectionButton.TooltipText = _selectionButton.Caption;
            }
            else if (declaration == null && _vbe.ActiveCodePane == null)
            {
                UiDispatcher.Invoke(() => _selectionButton.Caption = string.Empty);
            }
            else if (declaration != null && !declaration.IsBuiltIn && declaration.DeclarationType != DeclarationType.ClassModule && declaration.DeclarationType != DeclarationType.ProceduralModule)
            {
                var typeName = declaration.HasTypeHint
                    ? Declaration.TypeHintToTypeName[declaration.TypeHint]
                    : declaration.AsTypeName;

                _selectionButton.Caption = string.Format("{0}|{1}: {2} ({3}{4})",
                                                         declaration.QualifiedSelection.Selection,
                                                         declaration.QualifiedName.QualifiedModuleName,
                                                         declaration.IdentifierName,
                                                         RubberduckUI.ResourceManager.GetString("DeclarationType_" + declaration.DeclarationType, Settings.Settings.Culture),
                                                         string.IsNullOrEmpty(declaration.AsTypeName) ? string.Empty : ": " + typeName);

                _selectionButton.TooltipText = string.IsNullOrEmpty(declaration.DescriptionString)
                    ? _selectionButton.Caption
                    : declaration.DescriptionString;
            }
            else if (declaration != null)
            {
                // todo: confirm this is what we want, and then refator
                var selection = _vbe.ActiveCodePane.GetQualifiedSelection();
                if (selection.HasValue)
                {
                    var typeName = declaration.HasTypeHint
                        ? Declaration.TypeHintToTypeName[declaration.TypeHint]
                        : declaration.AsTypeName;

                    _selectionButton.Caption = string.Format("{0}|{1}: {2} ({3}{4})",
                                                             selection.Value.Selection,
                                                             declaration.QualifiedName.QualifiedModuleName,
                                                             declaration.IdentifierName,
                                                             RubberduckUI.ResourceManager.GetString("DeclarationType_" + declaration.DeclarationType, Settings.Settings.Culture),
                                                             string.IsNullOrEmpty(declaration.AsTypeName) ? string.Empty : ": " + typeName);
                }
                _selectionButton.TooltipText = string.IsNullOrEmpty(declaration.DescriptionString)
                    ? _selectionButton.Caption
                    : declaration.DescriptionString;
            }
        }
Ejemplo n.º 3
0
 private void SetSelectionText(QualifiedSelection selection)
 {
     UiDispatcher.Invoke(() => _selectionButton.Caption = selection.ToString());
 }
Ejemplo n.º 4
0
        public void SetStatusText(string value = null)
        {
            var text = value ?? RubberduckUI.ResourceManager.GetString("ParserState_" + _state.Status, Settings.Settings.Culture);

            UiDispatcher.Invoke(() => _statusButton.Caption = text);
        }