NeoKolors.Tui.Lifecycle.Apps 2026.4.0-preview.2

This is a prerelease version of NeoKolors.Tui.Lifecycle.Apps.
dotnet add package NeoKolors.Tui.Lifecycle.Apps --version 2026.4.0-preview.2
                    
NuGet\Install-Package NeoKolors.Tui.Lifecycle.Apps -Version 2026.4.0-preview.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NeoKolors.Tui.Lifecycle.Apps" Version="2026.4.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NeoKolors.Tui.Lifecycle.Apps" Version="2026.4.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="NeoKolors.Tui.Lifecycle.Apps" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NeoKolors.Tui.Lifecycle.Apps --version 2026.4.0-preview.2
                    
#r "nuget: NeoKolors.Tui.Lifecycle.Apps, 2026.4.0-preview.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NeoKolors.Tui.Lifecycle.Apps@2026.4.0-preview.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NeoKolors.Tui.Lifecycle.Apps&version=2026.4.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NeoKolors.Tui.Lifecycle.Apps&version=2026.4.0-preview.2&prerelease
                    
Install as a Cake Tool

NeoKolors.Tui.Lifecycle.Apps

Build & Test NuGet Version NuGet Downloads License

NeoKolors.Tui.Lifecycle.Apps provides the application hosting infrastructure, execution loop strategies, window focus management, and view binding for interactive TUI applications.


Key Components

1. Application Host (AppLifecycleHost)

AppLifecycleHost coordinates application states:

  • Activation State: AppActivationState (ACTIVE, INACTIVE, SUSPENDED).
  • Focus Management: Automatically manages whether the terminal has OS window focus (HasFocus).
  • Terminal Resizing: Responds to terminal resize events (NotifyWindowResized(width, height)).
  • Graceful Termination: Handles close requests (RequestClose(), CloseRequested event with cancellation option).
using NeoKolors.Tui.Lifecycle.Apps;

var host = new AppLifecycleHost();

host.CloseRequested += (sender, e) => {
    if (HasUnsavedChanges()) {
        e.Cancel = true; // Prevent shutdown
        ShowUnsavedDialog();
    }
};

host.Start();

2. View Presenter (NKAppView)

NKAppView connects a root IElement layout tree to an ICharScreen and HitMap:

  • Manages dirty tracking (Invalidate(), IsDirty, ResetDirty()).
  • Fires lifecycle events: BeforeRender, Render, AfterRender.
  • Replaces or updates the active UI hierarchy seamlessly (view.RootElement = BuildUi()).
using NeoKolors.Tui.Lifecycle.Apps;

var view = new NKAppView(rootElement, screen, hitMap);

// Trigger re-render whenever state changes
stateSignal.Changed += () => {
    view.RootElement = BuildUpdatedUi();
    view.Invalidate();
};

3. Rendering Loop Strategies (IAppLoopStrategy)

ThrottledAppLoopStrategy

Maintains high frame rates when the application is focused, and throttles down when the application loses focus:

  • ActiveFps: Target FPS when focused (e.g. 60 FPS).
  • BackgroundFps: Target FPS when inactive (e.g. 10 FPS) to drastically reduce CPU usage.
  • RenderOnlyWhenDirty: Only renders frames if view.IsDirty is true.
  • SignalWakeup(): Thread-safe signal to immediately awaken the loop from sleeping on user interaction.
var loopStrategy = new ThrottledAppLoopStrategy {
    ActiveFps = 60,
    BackgroundFps = 10,
    RenderOnlyWhenDirty = true
};

while (host.State != LifecycleState.STOPPED) {
    loopStrategy.Tick(host, view);
}
LazyAppLoopStrategy

Designed for classic terminal utilities:

  • Remains completely asleep until an input event, resize notification, or wakeup signal is dispatched.
  • Uses 0% CPU while idle.

Complete Boilerplate Example

See Examples/ExampleApp.cs for a complete production-grade application loop using AppLifecycleHost, NKAppView, and ThrottledAppLoopStrategy.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.4.0-preview.2 0 10/30/2026
2026.4.0-preview.1 55 10/23/2026