Using GeckoFX in a multithreaded application

后端 未结 2 1433
谎友^
谎友^ 2021-01-24 08:27

I\'m having issues grasping how exactly to handle threads when using GeckoFX- it seems to throw errors constantly when trying to use the GeckoWebBrowser in other threads.

<
相关标签:
2条回答
  • 2021-01-24 08:59
    GeckoFx can only be called from the same thread on which it was initialized (normally the UI thread)
    

    so if you want to call GeckoFx Control, the method must come from the thread which initialized the GeckoFx Control,usually its UI thread as in your case. you can use BeginInvoke in Form class, try like this:

            this.BeginInvoke(new Action(() =>
            {
               browser.Navigate(txtUrl.Text);
                //your code
            }));
    
    0 讨论(0)
  • 2021-01-24 09:02

    This will solve your prob, put it at the end of your nav request:

    myGeckoFxBrowser.Navigate("about:blank");
    myGeckoFxBrowser.Document.Cookie = "";
    myGeckoFxBrowser.Stop();
    
    0 讨论(0)
提交回复
热议问题