I'm controlling the form1.webbrowser1 from a module so I have this loop after form1.webbrowser1.navigate:


Do While Form1.WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
System.Windows.Forms.Application.DoEvents()
Loop


System.Windows.Forms.Application.DoEvents() is causing an "attempted to read or write protected memory error"

How can I correct this?