C# Класс Bloom.NavigationIsolator

This class is used to ensure that only one instance of GeckoWebBrowser is allowed to navigate at a time. We don't know for sure that this constraint is (or always will be) necessary, but at least as long as we're doing Application.DoEvents() in various places it's probably a good idea. See BL-77. It is designed for dependency-injection as an application-wide singleton. To achieve the purpose, all users of GeckoWebBrowser.Navigate must make use of the Navigate() or NavigateIfIdle() methods of this class to perform navigation. This class will serialize the navigations. Each navigation should occur eventually, except that if navigation is already in progress, NavigateIfIdle will just return false. This is intended for Idle loop tasks which should simply be attempted again later if the system is not really idle (since a navigation is in progress). Doing all this is challenging because the various possible events that might signal that navigation is complete are not reliable. Moreover it seems that the IsBusy flag (ReadyState, in later versions of Gecko) is also not reliable, and sometimes indicates that a browser is busy long after it has finished doing anything we recognize. We therefore use a timer to make sure we notice pretty soon if IsBusy becomes false without any of the events being raised. We will also notice at once that IsBusy has become false (or the target browser has been disposed) if a new request is received. As a last resort, rather than freeze the program or even the thumbnailing forever, if two seconds goes by and the browser is still busy doing one navigation we give up and forget that one and allow others to proceed.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Navigate ( Gecko.GeckoWebBrowser browser, string url ) : void

Navigate the specified browser to the specified url as soon as it is safe to do so (that is, immediately or when all other navigations we know about that were started sooner have completed). Must be called on UI thread.

NavigateIfIdle ( Gecko.GeckoWebBrowser browser, string url ) : bool

If no browser is navigating, navigate normally to the specified address and return true. (Normal isolation will happen for any subsequent non-idle task started.) If some navigation is already happening, just return false. The navigation will not be queued to do later. Must be called on UI thread.

Приватные методы

Метод Описание
BrowserOnDocumentCompleted ( object sender, EventArgs eventArgs ) : void
Cleanup ( ) : void
CleanupTimer ( ) : void
ForceDocumentCompleted ( ) : void
Navigate ( IIsolatedBrowser browser, string url ) : void
NavigateIfIdle ( IIsolatedBrowser browser, string url ) : bool
StartTask ( NavigationTask task ) : void

Описание методов

Navigate() публичный Метод

Navigate the specified browser to the specified url as soon as it is safe to do so (that is, immediately or when all other navigations we know about that were started sooner have completed). Must be called on UI thread.
public Navigate ( Gecko.GeckoWebBrowser browser, string url ) : void
browser Gecko.GeckoWebBrowser
url string
Результат void

NavigateIfIdle() публичный Метод

If no browser is navigating, navigate normally to the specified address and return true. (Normal isolation will happen for any subsequent non-idle task started.) If some navigation is already happening, just return false. The navigation will not be queued to do later. Must be called on UI thread.
public NavigateIfIdle ( Gecko.GeckoWebBrowser browser, string url ) : bool
browser Gecko.GeckoWebBrowser
url string
Результат bool