void ShowKestrelLog_OnClick(object sender, MouseButtonEventArgs e) { e.Handled = true; var service = GetServiceByTag(sender); var pid = service.ProcId; IntPtr mainWindowHandle; do { mainWindowHandle = Process.GetProcessById(pid).MainWindowHandle; var pr = ParentProcessUtilities.GetParentProcess(pid); pid = pr?.Id ?? 0; } while (mainWindowHandle == IntPtr.Zero && pid != 0); if (mainWindowHandle != IntPtr.Zero) { WindowApi.ShowWindow(mainWindowHandle); } else { MessageBox.Show("Last Kestrel process was attached to none console window style.\n So if you want to see Kestrel log window, please stop and start Microserice again.", "There is not kestrel window-habdle"); } }
public int Show() { WindowApi.RegisterPaintCallBack(_windowPtr, OnPaint); return(WindowApi.ShowWindow(_windowPtr)); }