Results 1 to 3 of 3

Thread: UI Thread and Secondary thread interaction

Threaded View

  1. #1

    Thread Starter
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    UI Thread and Secondary thread interaction

    With threading, the WebBrowser control behaves abnormally.
    While other controls allow accessing properties and error out when trying to set it, the WebBrowser control behaves just the opposite. It allows to set the property and errors out when trying to access it.

    Anyone knows the reason why?


    Here's a small test:
    Code:
       Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            Dim th As New Threading.Thread(AddressOf DoWork3)
            th.IsBackground = True
            th.Start()
        End Sub
    
        Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Dim th As New Threading.Thread(AddressOf DoWork4)
            th.IsBackground = True
            th.Start()
        End Sub
    
        Private Sub DoWork3()
            TextBox1.Text = "test"                          '<-- this errors out
            WebBrowser1.DocumentText = "<html>test</html>"  '<-- this works
        End Sub
    
    
        Private Sub DoWork4()
            Dim txt = TextBox1.Text                         '<-- this works
            Dim wbdoc = WebBrowser1.DocumentText            '<-- this errors out
        End Sub
    Last edited by Pradeep1210; Jul 20th, 2010 at 02:44 PM.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

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