VBA

Moderators: PavlinII
Number of threads: 1673
Number of posts: 3078

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Thread Cross-thread operation not valid Posted by Hav0c #1 on 6 Sept 2010 at 3:07 PM
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.

    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")
            txtSearchText.Focus()
        Else
            trd = New Thread(AddressOf ThreadTask)
            trd.Start()

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

        End If


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
Regards



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.