|
|
@@ -0,0 +1,438 @@
|
|
|
+# Application.Run Terminology - Visual Guide
|
|
|
+
|
|
|
+This document provides visual representations of the Application execution lifecycle to clarify the terminology.
|
|
|
+
|
|
|
+## Current Terminology (Confusing)
|
|
|
+
|
|
|
+### The Problem: "Run" Everywhere
|
|
|
+
|
|
|
+```
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+โ Application.Run() โ โ High-level API
|
|
|
+โ โ
|
|
|
+โ "Run" means the complete lifecycle โ
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ Application.Begin(toplevel) โ โ "Begin" what?
|
|
|
+ โ โ
|
|
|
+ โ Returns: RunState โ โ Sounds like state data
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ Application.RunLoop(runState) โ โ "Run" again? Run vs RunLoop?
|
|
|
+ โ โ
|
|
|
+ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
+ โ โ while (running) โ โ
|
|
|
+ โ โ RunIteration() โ โ โ "Run" again? What's the difference?
|
|
|
+ โ โ ProcessInput() โ โ
|
|
|
+ โ โ Layout/Draw() โ โ
|
|
|
+ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ Application.End(runState) โ โ "End" what?
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+
|
|
|
+Issues:
|
|
|
+โ "Run" appears 4 times meaning different things
|
|
|
+โ RunState sounds like state, but it's a token
|
|
|
+โ Begin/End don't clarify what's beginning/ending
|
|
|
+โ RunLoop vs RunIteration relationship unclear
|
|
|
+```
|
|
|
+
|
|
|
+## Proposed Terminology - Option 1: Session-Based โญ
|
|
|
+
|
|
|
+### The Solution: Clear, Explicit Names
|
|
|
+
|
|
|
+```
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+โ Application.Run() โ โ High-level (unchanged)
|
|
|
+โ โ
|
|
|
+โ Complete lifecycle: Begin + ProcessEvents + End โ
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ Application.BeginSession(toplevel) โ โ
Clear: starting a session
|
|
|
+ โ โ
|
|
|
+ โ Returns: ToplevelSession โ โ
Clear: it's a session token
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ Application.ProcessEvents(session) โ โ
Clear: processing events
|
|
|
+ โ โ
|
|
|
+ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
+ โ โ while (running) โ โ
|
|
|
+ โ โ ProcessEventsIteration() โ โ โ
Clear: one iteration of processing
|
|
|
+ โ โ ProcessInput() โ โ
|
|
|
+ โ โ Layout/Draw() โ โ
|
|
|
+ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ Application.EndSession(session) โ โ
Clear: ending the session
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+
|
|
|
+Benefits:
|
|
|
+โ
"Session" clearly indicates bounded execution
|
|
|
+โ
"ProcessEvents" describes the action
|
|
|
+โ
BeginSession/EndSession are unambiguous
|
|
|
+โ
Terminology is consistent and clear
|
|
|
+```
|
|
|
+
|
|
|
+## Lifecycle Comparison
|
|
|
+
|
|
|
+### Application Lifecycle (Init/Shutdown) vs Session Lifecycle (Begin/ProcessEvents/End)
|
|
|
+
|
|
|
+```
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโ Application Lifetime โโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+โ โ
|
|
|
+โ Application.Init() โ Initialize once per application โ
|
|
|
+โ โโ Create driver โ
|
|
|
+โ โโ Initialize screen โ
|
|
|
+โ โโ Setup subsystems โ
|
|
|
+โ โ
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโ Session 1 โโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
+โ โ Application.BeginSession(window1) โ session1 โ โ
|
|
|
+โ โ โโ Initialize window1 โ โ
|
|
|
+โ โ โโ Layout window1 โ โ
|
|
|
+โ โ โโ Draw window1 โ โ
|
|
|
+โ โ โ โ
|
|
|
+โ โ Application.ProcessEvents(session1) โ โ
|
|
|
+โ โ โโ Event loop until RequestStop() โ โ
|
|
|
+โ โ โ โ
|
|
|
+โ โ Application.EndSession(session1) โ โ
|
|
|
+โ โ โโ Cleanup window1 โ โ
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
+โ โ
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโ Session 2 โโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
+โ โ Application.BeginSession(dialog) โ session2 โ โ
|
|
|
+โ โ Application.ProcessEvents(session2) โ โ
|
|
|
+โ โ Application.EndSession(session2) โ โ
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
+โ โ
|
|
|
+โ Application.Shutdown() โ Cleanup once per application โ
|
|
|
+โ โโ Dispose driver โ
|
|
|
+โ โโ Restore terminal โ
|
|
|
+โ โ
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+
|
|
|
+Key Insight: Multiple sessions within one application lifetime
|
|
|
+```
|
|
|
+
|
|
|
+## Event Flow During ProcessEvents
|
|
|
+
|
|
|
+### Current (Confusing)
|
|
|
+
|
|
|
+```
|
|
|
+RunLoop(runState)
|
|
|
+ โ
|
|
|
+ โโ> while (toplevel.Running)
|
|
|
+ โ
|
|
|
+ โโ> RunIteration(runState) โ What's the difference?
|
|
|
+ โ โ
|
|
|
+ โ โโ> MainLoop.RunIteration()
|
|
|
+ โ โ โโ> Process driver events
|
|
|
+ โ โ
|
|
|
+ โ โโ> Layout (if needed)
|
|
|
+ โ โโ> Draw (if needed)
|
|
|
+ โ
|
|
|
+ โโ> (repeat)
|
|
|
+```
|
|
|
+
|
|
|
+### Proposed (Clear)
|
|
|
+
|
|
|
+```
|
|
|
+ProcessEvents(session)
|
|
|
+ โ
|
|
|
+ โโ> while (toplevel.Running)
|
|
|
+ โ
|
|
|
+ โโ> ProcessEventsIteration(session) โ
Clear: one iteration of event processing
|
|
|
+ โ โ
|
|
|
+ โ โโ> MainLoop.RunIteration()
|
|
|
+ โ โ โโ> Process driver events
|
|
|
+ โ โ
|
|
|
+ โ โโ> Layout (if needed)
|
|
|
+ โ โโ> Draw (if needed)
|
|
|
+ โ
|
|
|
+ โโ> (repeat)
|
|
|
+```
|
|
|
+
|
|
|
+## Manual Control Pattern
|
|
|
+
|
|
|
+When you need fine-grained control over the event loop:
|
|
|
+
|
|
|
+### Current (Confusing)
|
|
|
+
|
|
|
+```
|
|
|
+RunState rs = Begin(toplevel); โ Begin what?
|
|
|
+EndAfterFirstIteration = true; โ End what?
|
|
|
+
|
|
|
+while (!done)
|
|
|
+{
|
|
|
+ RunIteration(ref rs, first); โ Run what? How does this relate to RunLoop?
|
|
|
+ first = false;
|
|
|
+
|
|
|
+ // Custom processing
|
|
|
+ DoMyCustomStuff();
|
|
|
+}
|
|
|
+
|
|
|
+End(rs); โ End what?
|
|
|
+```
|
|
|
+
|
|
|
+### Proposed (Clear)
|
|
|
+
|
|
|
+```
|
|
|
+ToplevelSession session = BeginSession(toplevel); โ
Clear: starting a session
|
|
|
+StopAfterFirstIteration = true; โ
Clear: stop after one iteration
|
|
|
+
|
|
|
+while (!done)
|
|
|
+{
|
|
|
+ ProcessEventsIteration(ref session, first); โ
Clear: process one iteration
|
|
|
+ first = false;
|
|
|
+
|
|
|
+ // Custom processing
|
|
|
+ DoMyCustomStuff();
|
|
|
+}
|
|
|
+
|
|
|
+EndSession(session); โ
Clear: ending the session
|
|
|
+```
|
|
|
+
|
|
|
+## RequestStop Flow
|
|
|
+
|
|
|
+### Current
|
|
|
+
|
|
|
+```
|
|
|
+User Action (e.g., Quit Key)
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+Application.RequestStop(toplevel)
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+Sets toplevel.Running = false
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+RunLoop detects !Running
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+RunLoop exits
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+Application.End() cleans up
|
|
|
+```
|
|
|
+
|
|
|
+### Proposed (Same flow, clearer names)
|
|
|
+
|
|
|
+```
|
|
|
+User Action (e.g., Quit Key)
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+Application.StopProcessingEvents(toplevel) โ
Clear: stops event processing
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+Sets toplevel.Running = false
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+ProcessEvents detects !Running
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+ProcessEvents exits
|
|
|
+ โ
|
|
|
+ โผ
|
|
|
+Application.EndSession() cleans up
|
|
|
+```
|
|
|
+
|
|
|
+## Nested Sessions (Modal Dialogs)
|
|
|
+
|
|
|
+```
|
|
|
+โโโโโโโโโโโโโโโ Main Window Session โโโโโโโโโโโโโโโ
|
|
|
+โ โ
|
|
|
+โ session1 = BeginSession(mainWindow) โ
|
|
|
+โ โ
|
|
|
+โ ProcessEvents(session1) starts... โ
|
|
|
+โ โ โ
|
|
|
+โ โ User clicks "Open Dialog" button โ
|
|
|
+โ โ โ
|
|
|
+โ โโ> โโโโโโโโโ Dialog Session โโโโโโโ โ
|
|
|
+โ โ โ โ โ
|
|
|
+โ โ โ session2 = BeginSession(dialog) โ
|
|
|
+โ โ โ โ โ
|
|
|
+โ โ โ ProcessEvents(session2) โ โ
|
|
|
+โ โ โ (blocks until dialog closes) โ โ
|
|
|
+โ โ โ โ โ
|
|
|
+โ โ โ EndSession(session2) โ โ
|
|
|
+โ โ โ โ โ
|
|
|
+โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
+โ โ โ
|
|
|
+โ โ (returns to main window) โ
|
|
|
+โ โ โ
|
|
|
+โ ...ProcessEvents continues โ
|
|
|
+โ โ
|
|
|
+โ EndSession(session1) โ
|
|
|
+โ โ
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+
|
|
|
+Key Insight: Sessions can be nested (modal dialogs)
|
|
|
+```
|
|
|
+
|
|
|
+## Complete Example Flow
|
|
|
+
|
|
|
+### Simple Application
|
|
|
+
|
|
|
+```
|
|
|
+START
|
|
|
+ โ
|
|
|
+ โโ> Application.Init() [Application Lifecycle]
|
|
|
+ โ โโ> Initialize driver, screen
|
|
|
+ โ
|
|
|
+ โโ> window = new Window()
|
|
|
+ โ
|
|
|
+ โโ> Application.Run(window) [High-level API]
|
|
|
+ โ โ
|
|
|
+ โ โโ> BeginSession(window) [Session begins]
|
|
|
+ โ โ โโ> Initialize, layout, draw
|
|
|
+ โ โ
|
|
|
+ โ โโ> ProcessEvents(session) [Event processing]
|
|
|
+ โ โ โโ> Loop until stopped
|
|
|
+ โ โ
|
|
|
+ โ โโ> EndSession(session) [Session ends]
|
|
|
+ โ โโ> Cleanup
|
|
|
+ โ
|
|
|
+ โโ> window.Dispose()
|
|
|
+ โ
|
|
|
+ โโ> Application.Shutdown() [Application Lifecycle]
|
|
|
+ โโ> Restore terminal
|
|
|
+END
|
|
|
+```
|
|
|
+
|
|
|
+### Application with Manual Control
|
|
|
+
|
|
|
+```
|
|
|
+START
|
|
|
+ โ
|
|
|
+ โโ> Application.Init()
|
|
|
+ โ
|
|
|
+ โโ> window = new Window()
|
|
|
+ โ
|
|
|
+ โโ> session = Application.BeginSession(window) [Manual Session Control]
|
|
|
+ โ โโ> Initialize, layout, draw
|
|
|
+ โ
|
|
|
+ โโ> Application.StopAfterFirstIteration = true
|
|
|
+ โ
|
|
|
+ โโ> while (!done) [Custom Event Loop]
|
|
|
+ โ โ
|
|
|
+ โ โโ> Application.ProcessEventsIteration(ref session, first)
|
|
|
+ โ โ โโ> Process one iteration
|
|
|
+ โ โ
|
|
|
+ โ โโ> DoCustomProcessing()
|
|
|
+ โ โ
|
|
|
+ โ โโ> first = false
|
|
|
+ โ
|
|
|
+ โโ> Application.EndSession(session) [Manual Session Control]
|
|
|
+ โ โโ> Cleanup
|
|
|
+ โ
|
|
|
+ โโ> window.Dispose()
|
|
|
+ โ
|
|
|
+ โโ> Application.Shutdown()
|
|
|
+END
|
|
|
+```
|
|
|
+
|
|
|
+## Terminology Mapping Summary
|
|
|
+
|
|
|
+### API Name Changes
|
|
|
+
|
|
|
+```
|
|
|
+CURRENT PROPOSED
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
+
|
|
|
+Application.Run() โ Application.Run() (unchanged)
|
|
|
+
|
|
|
+RunState โ ToplevelSession โ
Clear: session token
|
|
|
+
|
|
|
+Application.Begin() โ Application.BeginSession() โ
Clear: begin a session
|
|
|
+
|
|
|
+Application.RunLoop() โ Application.ProcessEvents() โ
Clear: processes events
|
|
|
+
|
|
|
+Application.RunIteration() โ Application.ProcessEventsIteration() โ
Clear: one iteration
|
|
|
+
|
|
|
+Application.End() โ Application.EndSession() โ
Clear: end the session
|
|
|
+
|
|
|
+Application.RequestStop() โ Application.StopProcessingEvents() โ
Clear: stops processing
|
|
|
+
|
|
|
+EndAfterFirstIteration โ StopAfterFirstIteration โ
Consistent naming
|
|
|
+
|
|
|
+NotifyNewRunState โ NotifyNewSession โ
Consistent naming
|
|
|
+
|
|
|
+NotifyStopRunState โ NotifyStopSession โ
Consistent naming
|
|
|
+
|
|
|
+RunStateEventArgs โ ToplevelSessionEventArgs โ
Consistent naming
|
|
|
+```
|
|
|
+
|
|
|
+## Benefits Visualized
|
|
|
+
|
|
|
+### Before: Confusion
|
|
|
+
|
|
|
+```
|
|
|
+User thinks:
|
|
|
+"What's the difference between Run, RunLoop, and RunIteration?"
|
|
|
+"Is RunState storing state or just a handle?"
|
|
|
+"What am I Beginning and Ending?"
|
|
|
+
|
|
|
+ โโโโโโโโโโโโโโโ
|
|
|
+ โ Run() โ โ What does "Run" mean exactly?
|
|
|
+ โโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โโโโโโโโโโโโโโโ
|
|
|
+ โ Begin() โ โ Begin what?
|
|
|
+ โโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โโโโโโโโโโโโโโโ
|
|
|
+ โ RunLoop() โ โ Is this the same as Run?
|
|
|
+ โโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โโโโโโโโโโโโโโโ
|
|
|
+ โ End() โ โ End what?
|
|
|
+ โโโโโโโโโโโโโโโ
|
|
|
+
|
|
|
+Result: User confusion, slower learning curve
|
|
|
+```
|
|
|
+
|
|
|
+### After: Clarity
|
|
|
+
|
|
|
+```
|
|
|
+User understands:
|
|
|
+"Run() does the complete lifecycle"
|
|
|
+"BeginSession/EndSession manage a session"
|
|
|
+"ProcessEvents processes events until stopped"
|
|
|
+"ToplevelSession is a token for the session"
|
|
|
+
|
|
|
+ โโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ Run() โ โ
Complete lifecycle
|
|
|
+ โโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ BeginSession() โ โ
Start a session
|
|
|
+ โโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ ProcessEvents() โ โ
Process events
|
|
|
+ โโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ
|
|
|
+ โโโโโโโโโโโโโโโโโโโ
|
|
|
+ โ EndSession() โ โ
End the session
|
|
|
+ โโโโโโโโโโโโโโโโโโโ
|
|
|
+
|
|
|
+Result: Clear understanding, faster learning curve
|
|
|
+```
|
|
|
+
|
|
|
+## See Also
|
|
|
+
|
|
|
+- [TERMINOLOGY_PROPOSAL.md](TERMINOLOGY_PROPOSAL.md) - Full proposal with rationale
|
|
|
+- [TERMINOLOGY_QUICK_REFERENCE.md](TERMINOLOGY_QUICK_REFERENCE.md) - Quick comparison tables
|
|
|
+- [TERMINOLOGY_INDUSTRY_COMPARISON.md](TERMINOLOGY_INDUSTRY_COMPARISON.md) - Industry patterns
|