private void waitForProcessAndActivate(Process process) { try { process.WaitForInputIdle(6000); var handle = process.MainWindowHandle; if (handle != IntPtr.Zero) { activateWindow(handle); } } catch (Exception ex) { Log.Debug(ex.ToString()); } } }