We are using an Internet Explorer object (Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null
) to open a explorer outside a WPF application.
We need to know when the explorer closes so we handle the OnQuit event but we are receiving the event multiple times due to unknown reasons depending on the URL.
The following POC demonstrates the issue:
using System;
namespace InternetExplorerQuitPOC
{
class Program
{
static void Main(string[] args)
{
do
{
SHDocVw.InternetExplorer internetExplorer;
internetExplorer = new SHDocVw.InternetExplorer();
internetExplorer.OnQuit += OnInternetExplorerOnOnQuit;
internetExplorer.ToolBar = 1;
internetExplorer.StatusBar = true;
internetExplorer.MenuBar = true;
internetExplorer.Visible = true;
object url = "https://www.notariado.org";
internetExplorer.Navigate2(ref url);
} while (Console.ReadKey() != null);
}
private static void OnInternetExplorerOnOnQuit()
{
Console.Out.WriteLine("Quit fired");
}
}
}