Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Thread Cross-thread operation not valid

Hav0c #1Hav0c #1 Member Posts: 50
Hey all
what i like to do is show a animated pictureBox while another function is being executed. Now the only way i know to do this is by using a thread.

this is a sample of my code.

[code] Private Sub ThreadTask()
'the pictureBox proparty is set to false that is why i am setting it to true now
picLoad.Visible = True
End Sub

Private Sub cmdFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFind.Click
If txtSearchText.Text = "" Then
MsgBox("Search fields can be empty.", MsgBoxStyle.Critical, "Input Error")
trd = New Thread(AddressOf ThreadTask)

'This is the other function that is being executed and it is in another class
DisplayResult(dgvSearch, 5, txtSearchText.Text)

End If[/code]

with the above code i get the following error "Cross-thread operation not valid" now i have read this article and that is based on C# can any one help me translate it to VB.NET
Sign In or Register to comment.