public void BringToFront() { try { logger.WriteLine(Strings.IDEWindowService_BringingToFront); var handle = process.GetCurrentProcessMainWindowHandle(); if (handle == IntPtr.Zero) { logger.WriteLine(Strings.IDEWindowService_InvalidWindowHandle); return; } RestoreIfMinimized(handle); BringToFront(handle); // We'll still try to "set foreground" even if one of the restore calls failed } catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex)) { logger.WriteLine(Strings.IDEWindowService_GeneralError, ex.Message); } }