Table of Contents

Method Execute

Namespace
Terminal.Gui.App
Assembly
Terminal.Gui.dll

Execute<T>(Func<ResultEventArgs<T>, bool>, EventHandler<ResultEventArgs<T>>?, ResultEventArgs<T>, Action?)

Executes a single-phase CWP workflow with a virtual method, event, and optional default action.

public static bool? Execute<T>(Func<ResultEventArgs<T>, bool> onMethod, EventHandler<ResultEventArgs<T>>? eventHandler, ResultEventArgs<T> args, Action? defaultAction = null)

Parameters

onMethod Func<ResultEventArgs<T>, bool>

The virtual method invoked first, returning true to mark the workflow as handled.

eventHandler EventHandler<ResultEventArgs<T>>

The event handler to invoke, or null if no handlers are subscribed.

args ResultEventArgs<T>

The event arguments containing a result and handled status.

defaultAction Action

The default action to execute if the workflow is not handled, or null if none.

Returns

bool?

True if the workflow was handled, false if not, or null if no event handlers are subscribed.

Type Parameters

T

The type of the result in the event arguments.

Examples

ResultEventArgs<bool> args = new();
Func<ResultEventArgs<bool>, bool> onAccepting = _ => false;
EventHandler<ResultEventArgs<bool>>? acceptingHandler = null;
Action? defaultAction = () => args.Result = true;
bool? handled = CWPWorkflowHelper.Execute(onAccepting, acceptingHandler, args, defaultAction);

Exceptions

ArgumentNullException

Thrown if onMethod or args is null.