views:

62

answers:

1

I'm using a WinForms WebBrowser control and am noticing that when the page I'm on forces a refresh from it's end and the control starts to re-render the page, it binds up the entire C# GUI that the control is in.

Is there any way to get the browser control to run on a thread other than the GUI thread so that it updates the pages in a separate context?

A: 

You can use BackGroundWorker class if you are using .net framework 2.0 onwards.

private BackgroundWorker bgSearch = new BackgroundWorker();

bgSearch.DoWork += new DoWorkEventHandler(bgSearch_DoWork);

        bgSearch.RunWorkerCompleted += new RunWorkerCompletedEventHandler
        (bgSearch_RunWorkerCompleted);


        bgSearch.WorkerReportsProgress = true;
        bgSearch.WorkerSupportsCancellation = true;



    void bgSearch_DoWork(object sender, DoWorkEventArgs e)
    {

        // start downloading here. you need to check Control.IsInoverequired if       your     webbrower control is on the UI thread

    }




      void bgSearch_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
       // any cleanup code here.

    }
saurabh
This would work even if I want the browser control to always be running?
Adam Haile