Current terminology has two specific issues:
RunState sounds like state data, but it's actually a token/handleEndAfterFirstIteration uses "End" but controls loop behavior, not lifecycle| Current | Proposed | Why |
|---|---|---|
RunState |
RunToken |
Clear it's a token, not state data |
EndAfterFirstIteration |
StopAfterFirstIteration |
"Stop" aligns with RequestStop, clearly about loop control |
| API | Why It Works |
|---|---|
Begin / End |
Clear, concise lifecycle pairing |
RequestStop |
"Request" appropriately conveys non-blocking |
RunLoop / RunIteration |
Distinction is important: RunLoop starts the driver's mainloop, RunIteration processes one iteration |
// What is RunState? State data or a handle?
RunState rs = Application.Begin(window);
Application.RunLoop(rs);
Application.End(rs);
// Does this call End()? No, it controls RunLoop()
Application.EndAfterFirstIteration = true;
// Clearly a token, not state data
RunToken token = Application.Begin(window);
Application.RunLoop(token);
Application.End(token);
// Clearly controls loop stopping, aligns with RequestStop
Application.StopAfterFirstIteration = true;
Important distinction to preserve:
RunLoop(token): RunIteration(token):
┌──────────────────┐ ┌──────────────────┐
│ Starts driver's │ │ Processes ONE │
│ MainLoop │ │ iteration: │
│ │ │ - Events │
│ Loops calling: │ │ - Layout │
│ RunIteration() │ │ - Draw │
│ RunIteration() │ │ │
│ ... │ │ Returns │
│ │ │ immediately │
│ Until stopped │ │ │
└──────────────────┘ └──────────────────┘
This distinction is valuable and should be kept.
Application.Run(window) ← High-level: complete lifecycle
├─ Application.Begin(window) → RunToken
│ └─ Initialize, layout, draw
├─ Application.RunLoop(token)
│ └─ Loop: while(running) { RunIteration() }
└─ Application.End(token)
└─ Cleanup
Application.RunIteration(ref token) ← Low-level: one iteration
Application.RequestStop() ← Signal loop to stop
Application.StopAfterFirstIteration ← Mode: stop after 1 iteration
| Option | Pros | Cons |
|---|---|---|
| RunToken ⭐ | Clear, concise | New term |
| ExecutionContext | Industry standard | Longer |
| RunHandle | Clear | Win32-ish |
| Option | Pros | Cons |
|---|---|---|
| StopAfterFirstIteration ⭐ | Aligns with RequestStop | Slightly longer |
| SingleIteration | Shorter | Less obvious |
| RunLoopOnce | Explicit | Awkward |
// Old code continues to work with obsolete warnings
[Obsolete("Use RunToken instead")]
public class RunState { ... }
[Obsolete("Use StopAfterFirstIteration instead")]
public static bool EndAfterFirstIteration
{
get => StopAfterFirstIteration;
set => StopAfterFirstIteration = value;
}
// New code uses clearer names
public class RunToken { ... }
public static bool StopAfterFirstIteration { get; set; }
// Before
RunState rs = Application.Begin(window);
Application.EndAfterFirstIteration = true;
Application.RunLoop(rs);
Application.End(rs);
// After (simple find/replace)
RunToken token = Application.Begin(window);
Application.StopAfterFirstIteration = true;
Application.RunLoop(token);
Application.End(token);
Problem: Users see "State" and think it holds state data. They ask:
Solution: "Token" clearly indicates it's an identity/handle for Begin/End pairing, like CancellationToken.
Problem: Users see "End" and think of End() method. They ask:
End()?"Solution: "Stop" aligns with RequestStop and clearly indicates loop control, not lifecycle cleanup.
✅ Keep as-is - Clear, concise lifecycle pairing
✅ Keep as-is - Appropriately conveys non-blocking nature
✅ Keep as-is - Distinction is important and understood
Changes (2 names only):
RunState → RunTokenEndAfterFirstIteration → StopAfterFirstIterationBenefits:
See TERMINOLOGY_PROPOSAL.md for detailed analysis.