private void InitialiseBrowser(WebBrowser browser, string template) { browser.AllowNavigation = false; browser.AllowWebBrowserDrop = false; using (Stream xmlStream = this.GetType().Assembly.GetManifestResourceStream(template)) { CompletionClosure.LoadSynchronously(browser, xmlStream); } }
public static void LoadSynchronously(WebBrowser b, Stream page) { CompletionClosure cc = new CompletionClosure(); b.DocumentCompleted += cc.Handler; try { b.DocumentStream = page; while (!cc.done) { Application.DoEvents(); System.Threading.Thread.Sleep(0); } } finally { b.DocumentCompleted -= cc.Handler; } }