The following code can run for several hours with no issues, the problem is that it keeps crashing randomly:

Code:
Dispatcher.Invoke(new Action(() => { webBrowser.Source = siteUri; }));
Dispatcher.Invoke(new Action(() => { labelWebBrowserPreview.Content = url; }));

System.Threading.Thread.Sleep(30000);

result = Dispatcher.Invoke(() =>
{ return webBrowser.Document; });

mshtml.HTMLDocument document = result as HTMLDocument;
string source ="";
if (document != null)
{
    var x = document.doctype;
    source = document.documentElement.innerHTML;
}
The basic idea is to check websites around every 15 minutes and get the web browser content.

I highly suspect that it is because I do not check correctly if the document.doctype is correctly set.

I looked around on the web a little and sleep was the only way I could think of to let some time for the web browser to load the page correctly with a dispatcher.

The following error is what crashes the application:

Web Change Tracker bug #0001_01.jpg

Note: This is a WPF application.

May you give some help with this please?

Thank you for your time and help, it is greatly appreciated.