Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Thread Cross-thread operation not valid
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
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)
with the above code i get the following error "Cross-thread operation not valid" now i have read this article http://www.vcskicks.com/cross-thread.php
and that is based on C# can any one help me translate it to VB.NET
0 · ·