Skip to content
ConsoleMonster

API Reference

Class

TerminalGuard

Namespace ConsoleMonster.Output
Assembly ConsoleMonster
Implements
IDisposable
Modifiers sealed

Restores the screen and saved Windows output mode on disposal, termination or a second Ctrl+C.

Inheritance

  • Object
  • TerminalGuard

Constructors

public TerminalGuard(Action restore, Boolean handleCancelKey = true) #

Creates a guard, saving the output mode and hooking process termination events.

Parameters

restore System.Action requiredposition: 0
Restores the screen, cursor, attributes and host output routing.
handleCancelKey System.Boolean = true optionalposition: 1
Whether to intercept Ctrl+C.

Methods

public Void Dispose() #
Returns: Void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public Void Restore() #
Returns: Void

Restores once; callback and native errors never escape this method.

Properties

public CancellationToken Cancellation { get; } #

Cancelled on the first Ctrl+C or when the guard is disposed.

public Boolean RestoreCompleted { get; } #

Whether the restore callback and mode-restoration attempt have completed.