This error comes when you tries to add items in list box (or any other control) in thread (or from the function which is being used by thread).
Below is solution:
Private Delegate Sub stringDelegate(ByVal s As String)
Private Sub AddItem(ByVal s As String)
If ListBox1.InvokeRequired Then
Dim sd As New stringDelegate(AddressOf AddItem)
Me.Invoke(sd, New Object() {s})
Else
ListBox1.Items.Add(s)
End If
End Sub
now just pass your value in "AddItem()" and it will be added in listbox.
Cross-thread operation not valid: Control 'ListBox1' accessed from a thread other than the thread it was created on
Posted by
Rajesh Rolen
at
Tuesday, January 5, 2010
Labels: C#.NET and VB.NET Interview Questions , Threading , VB.NET
8 comments:
Keep posting stuff like this i really like it
Hi folks... I am brand new here but I can't wait to start having/getting several good chats along with you all! I just figured i would introduce myself to you all so hello!
Hi,
I just came across to dotnetacademy.blogspot.com from google and I find dotnetacademy.blogspot.com very interesting.
I wish, can make lot's of new friend here :)
clips lesbians making out
I totally support that! Continue that way!
Hi Everyone! I hope all is well and I look forward to be a great contributor to this community. Feel free to introduce yourself so I can get to know you better...
проститутки индивидуалки краснодара спб академическая проститутки проститутки на дорогах москвы дешовые проститутки питера шлюха com
You were not mistaken, truly
Post a Comment