IMainLoopCoordinator.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. /// <param name="app"></param>
  19. /// <remarks>
  20. /// This method:
  21. /// <list type="number">
  22. /// <item>Starts the input thread that reads console input asynchronously</item>
  23. /// <item>Initializes the main UI loop on the calling thread</item>
  24. /// <item>Waits for both to be ready before returning</item>
  25. /// </list>
  26. /// </remarks>
  27. /// <returns>A task that completes when initialization is done</returns>
  28. public Task StartInputTaskAsync (IApplication? app);
  29. /// <summary>
  30. /// Stops the input thread and performs cleanup.
  31. /// </summary>
  32. /// <remarks>
  33. /// This method blocks until the input thread has exited.
  34. /// It must be called only from the main UI thread.
  35. /// </remarks>
  36. public void Stop ();
  37. /// <summary>
  38. /// Executes a single iteration of the main UI loop.
  39. /// </summary>
  40. /// <remarks>
  41. /// Each iteration processes input, runs timeouts, checks for UI changes,
  42. /// and renders any necessary updates.
  43. /// </remarks>
  44. void RunIteration ();
  45. }