namespace Terminal.Gui.Views; /// /// Base implementation of for views that can be run as blocking sessions. /// /// The type of result data returned when the session completes. /// /// /// Views can derive from this class or implement directly. /// /// /// This class provides default implementations of the interface /// following the Terminal.Gui Cancellable Work Pattern (CWP). /// /// /// For views that don't need to return a result, use instead. /// /// /// This class inherits from to avoid code duplication and ensure consistent behavior. /// /// public class Runnable : Runnable, IRunnable { /// /// Constructs a new instance of the class. /// public Runnable () { // Base constructor handles common initialization } /// public new TResult? Result { get => base.Result is TResult typedValue ? typedValue : default; set => base.Result = value; } /// /// Override to clear typed result when starting. /// Called by base before events are raised. /// protected override bool OnIsRunningChanging (bool oldIsRunning, bool newIsRunning) { // Clear previous typed result when starting if (newIsRunning) { Result = default; } // Call base implementation to allow further customization return base.OnIsRunningChanging (oldIsRunning, newIsRunning); } }