Results 1 to 4 of 4

Thread: [RESOLVED] Interacting W/ WebBrowser in a BackgroundWorker

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2008
    Posts
    75

    Resolved [RESOLVED] Interacting W/ WebBrowser in a BackgroundWorker

    Hey guys, anyone have any ideas on how i would go about filling text boxes and submitting forms in a new thread/BackgroundWorker?

    because everytime i try i keep getting cross thread errors...

    Would i have to create the web browser in the do work event? or is there a better way to go about this?

    because my users see the page as its getting manipulated, and i do not want them not to be able to see whats going on, which i think would be the case if i created a new browser in the thread...

    any suggestions would be much appreciated.
    Last edited by ahostbr; Oct 29th, 2008 at 04:51 PM.
    How To Make A Youtube Downloader
    I use Visual Studio 2008 Pro...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Interacting W/ WebBrowser in a BackgroundWorker

    You can't access most members of a control in a thread other than the one that created it, plain and simple. If you want the user to see the WebBrowser then it must be created in the UI thread. You can do some processing in a worker thread but anything that actually manipulates the UI must be done in the UI thread. There's no avoiding it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2008
    Posts
    75

    Re: Interacting W/ WebBrowser in a BackgroundWorker

    ok thx jm, so second question, how would i create the web browser in a new thread?
    How To Make A Youtube Downloader
    I use Visual Studio 2008 Pro...

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Interacting W/ WebBrowser in a BackgroundWorker

    If you want a control created on a particular thread then you simply create it in a method that is executed on that thread. Like I said though, you can't then display it to the user on a form that was created on the main thread.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width