/// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        /// <param name="disposing"> True if disposing and false if otherwise. </param>
        protected override void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            try
            {
                if (_browser == null || !AutoClose)
                {
                    return;
                }

                WaitForComplete();

                // We cannot allow the browser to close within a second.
                // I assume that add-on(s) need time to start before closing the browser.
                var timeout = TimeSpan.FromMilliseconds(1000);
                var watch   = Stopwatch.StartNew();

                while (watch.Elapsed <= timeout)
                {
                    Thread.Sleep(50);
                }

                _browser.Quit();
            }
            catch
            {
                _browser = null;
            }
        }
Exemple #2
0
 public void Dispose()
 {
     ie.Quit();
 }