Table of Contents

Class ConsoleBreakHandler

Namespace
RDCore.SDK.ConsoleIO
Assembly
RDCore.SDK.dll

Turns the console's break keys into a callback for as long as it is alive, instead of letting them end the process.

public sealed class ConsoleBreakHandler : IDisposable
Inheritance
ConsoleBreakHandler
Implements
Inherited Members

Remarks

An interactive shell needs Ctrl+C and Ctrl+Break to mean "stop what you are doing" — the RUN/STOP key, not "quit" — which is only true while something owns them. Disposing hands them back.

Cancelling the default behaviour is best-effort for Ctrl+Break specifically: some hosts terminate the process on it whatever a handler asks for. It is honoured for Ctrl+C, which is why a shell should treat both as the same key rather than relying on either alone.

Constructors

ConsoleBreakHandler(Action)

Starts intercepting the break keys.

public ConsoleBreakHandler(Action onBreak)

Parameters

onBreak Action

Runs on the console's own handler thread, so it must return promptly — signal something and let the shell react, rather than doing the work here.

Methods

Dispose()

Stops intercepting the break keys.

public void Dispose()