ChildProcessStateBagForWin.cs 719 B

123456789101112131415161718192021
  1. namespace SinMaiLauncher.ChildProcessHolder;
  2. internal class ChildProcessStateBagForWin(ChildProcessKind kind, IProcessStartInfo startInfo) : ChildProcessStateBag(kind, startInfo)
  3. {
  4. public nint? HWndMainWindow => MainWindowHWnd;
  5. protected override async Task<bool> CheckReadyAsync()
  6. {
  7. Status = ChildProcessStatus.WaitingReady;
  8. if (await WaitForInputIdleAsync(TimeSpan.FromSeconds(5)) == false) return false;
  9. return true;
  10. }
  11. public override async Task StopAsync(TimeSpan timeout)
  12. {
  13. Status = ChildProcessStatus.Stopping;
  14. CloseMainForm();
  15. await Task.WhenAny(Task.Delay(timeout), WaitForExitAsync());
  16. await base.StopAsync(timeout);
  17. }
  18. }