BusinessProcessInvoke(Command, Object) Method

Invokes a command that will be handled by an Handler.

Definition

Namespace: Firefly.Box
Assembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
C#
public void Invoke(
	Command command,
	params Object[] untypedArgs
)

Parameters

command  Command
The Command to be invoked
untypedArgs  Object
Arguments to be sent to the Handler that will handle the invoked command

Remarks

When the Handler method is called, the framework will iterate the Handlers property collection until it will find an Handler that matches the command.
If no matching Handler was found, or if the Handled property was set to true, the framework will iterate the calling task's Handlers property collection and so on.
The deference between Raise and Invoke, is that Raise will queue the command, and process it the next time the framework is idle, while Invoke will process it immediately
When invoking a {0} (for example {1}) or a Key Combination, only the relevant Handlers will execute, but the command it self will not. In order to run the command itself use .

Example

deference between invoke and raise
C#
using System;
using System.Collections.Generic;
using System.Text;

using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
{
    public class DifferenceBetweenRaiseAndInvoke
    {
        public void DemoRaiseAndInvoke()
        {
            var uic = new UIController
            {
                View = new Firefly.Box.UI.Form()
            };
            var myCommand = new CustomCommand();
            var h = uic.Handlers.Add(myCommand);
            h.Invokes += e =>
            {
                e.Handled = false;
                System.Windows.Forms.MessageBox.Show("First Handler");
            };
            var h2 = uic.Handlers.Add(myCommand);
            h2.Invokes += e =>
            {
                e.Handled = false;
                System.Windows.Forms.MessageBox.Show("Second Handler");
            };
            var invokeButton = new Firefly.Box.UI.Button
            {
                Text = "Invoke"
            };
            invokeButton.Click += (a, b) =>
            {
                System.Windows.Forms.MessageBox.Show("Before Invoke");
                uic.Invoke(myCommand);
                System.Windows.Forms.MessageBox.Show("After Invoke");
            };

            uic.View.Controls.Add(invokeButton);

            var raiseButton = new Firefly.Box.UI.Button
            {
                Text = "Raise",
                Top = invokeButton.Bottom + 5
            };
            raiseButton.Click += (a, b) =>
            {
                System.Windows.Forms.MessageBox.Show("Before Raise");
                uic.Raise(myCommand);
                System.Windows.Forms.MessageBox.Show("After Raise");
            };
            uic.View.Controls.Add(raiseButton);
            uic.Run();

        }
    }
}

See Also