Table of Contents

Class RunnableWrapper<TView, TResult>

Namespace
Terminal.Gui.ViewBase
Assembly
Terminal.Gui.dll

Wraps any View to make it runnable with a typed result, similar to how FlagSelector<TFlagsEnum> wraps FlagSelector.

public class RunnableWrapper<TView, TResult> : Runnable<TResult>, IDisposable, ISupportInitializeNotification, ISupportInitialize, IRunnable<TResult>, IRunnable where TView : View

Type Parameters

TView

The type of view being wrapped.

TResult

The type of result data returned when the session completes.

Inheritance
Runnable<TResult>
RunnableWrapper<TView, TResult>
Implements
IRunnable<TResult>
Inherited Members
Extension Methods

Remarks

This class enables any View to be run as a blocking session with Run(Func<Exception, bool>?, string?) without requiring the View to implement IRunnable<TResult> or derive from Runnable<TResult>.

Use AsRunnable<TView, TResult>(TView, Func<TView, TResult?>) for a fluent API approach, or RunView<TView, TResult>(IApplication, TView, Func<TView, TResult?>, Func<Exception, bool>?) to run directly.

<pre><code class="lang-csharp">// Wrap a TextField to make it runnable with string result
var textField = new TextField { Width = 40 };
var runnable = new RunnableWrapper<TextField, string> { WrappedView = textField };

// Extract result when stopping
runnable.IsRunningChanging += (s, e) =>
{
    if (!e.NewValue) // Stopping
    {
        runnable.Result = runnable.WrappedView.Text;
    }
};

app.Run(runnable);
Console.WriteLine($"User entered: {runnable.Result}");
runnable.Dispose();</code></pre>

Constructors

RunnableWrapper()

Initializes a new instance of RunnableWrapper<TView, TResult>.

Properties

WrappedView

Gets or sets the wrapped view that is being made runnable.

Methods

EndInit()

Signals the View that initialization is ending. See ISupportInitialize.