Console application lifecycle¶
ConsoleBase<TArgContainer>.Run() executes the standardized application lifecycle — Initialize(), Execute(), Finish() — for the concrete application instance resolved by the program runner entry point.
| Field | Value |
|---|---|
| Operation ID | OP-WIN-002 |
| Trigger | Called by program runner entry point step 8, on the container-resolved application instance. |
| Inputs | State established by the constructor (Arguments, StartTime, injected IConsoleLogService). |
| Outputs | Environment.ExitCode reset to 0 at the start of this method; console header/footer log lines. |
| Primary components | ConsoleBase<TArgContainer>.Run(), Dispose() |
| Entry point | Console\SAIF.Console\Console\ConsoleBase.cs |
Steps¶
Initialize()— abstract, app-specific one-time setup.Environment.ExitCode = 0— set unconditionally afterInitialize()returns (BR-WIN-006: a successfulInitialize()always resets any pre-existing non-zero exit code beforeExecute()runs).Execute()— abstract, app-specific main logic.Finish()— abstract, app-specific cleanup.- Separately, on
Dispose()(not part ofRun()):WriteFooter()thenlogService.Dispose()— writes the "ended at"/"ran for N seconds" lines and disposes all registeredLogWriters.
Note: WriteHeader() runs earlier, in the constructor (before Run() is ever called), writing the "began at" line.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Run invoked]) --> Init[Initialize]
Init --> Reset[Environment.ExitCode = 0]
Reset --> Execute[Execute]
Execute --> Finish[Finish]
Finish --> EndOk([Run returns])
EndOk -.->|On Dispose| Footer[WriteFooter + logService.Dispose]
Failure and edge-case behavior¶
Environment.ExitCodeis always reset to0afterInitialize()succeeds, discarding any prior non-zero value set before this call — this happens regardless of whatExecute()/Finish()subsequently do.WriteFooter()and log-service disposal run only onDispose(), not as part ofRun()— a consuming application that does not dispose the resolvedConsoleBaseinstance never writes the footer or flushes/disposes log writers.
Related documentation¶
Sources¶
Console\SAIF.Console\Console\ConsoleBase.cs