IMainLoopCoordinator.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. namespace Terminal.Gui.App;
  2. /// <summary>
  3. /// Interface for the main loop coordinator that manages UI loop initialization and threading.
  4. /// </summary>
  5. /// <remarks>
  6. /// The coordinator is responsible for:
  7. /// <list type="bullet">
  8. /// <item>Starting the asynchronous input reading thread</item>
  9. /// <item>Initializing the main UI loop on the application thread</item>
  10. /// <item>Coordinating clean shutdown of both threads</item>
  11. /// </list>
  12. /// </remarks>
  13. public interface IMainLoopCoordinator
  14. {
  15. /// <summary>
  16. /// Initializes all required subcomponents and starts the input thread.
  17. /// </summary>
  18. /// <remarks>
  19. /// This method:
  20. /// <list type="number">
  21. /// <item>Starts the input thread that reads console input asynchronously</item>
  22. /// <item>Initializes the main UI loop on the calling thread</item>
  23. /// <item>Waits for both to be ready before returning</item>
  24. /// </list>
  25. /// </remarks>
  26. /// <returns>A task that completes when initialization is done</returns>
  27. public Task StartInputTaskAsync ();
  28. /// <summary>
  29. /// Stops the input thread and performs cleanup.
  30. /// </summary>
  31. /// <remarks>
  32. /// This method blocks until the input thread has exited.
  33. /// It must be called only from the main UI thread.
  34. /// </remarks>
  35. public void Stop ();
  36. /// <summary>
  37. /// Executes a single iteration of the main UI loop.
  38. /// </summary>
  39. /// <remarks>
  40. /// Each iteration processes input, runs timeouts, checks for UI changes,
  41. /// and renders any necessary updates.
  42. /// </remarks>
  43. void RunIteration ();
  44. }