Run two processes simultaneously in vb.net windows form. Multithreaded operation.
Posted on 2008-11-11
I would be grateful for your help on the following issue.
I have a windows form which has a search facility and this can sometimes take up to 10 seconds depending on the type of search being carried out. Therefore I want to update the user with a label that continually changes from one message to the other while the search is being carried out. For example after clicking the search button the label might display "Working...." for two seconds and then go to "Please wait.....". Also, just for the effect, I want the search to take a minimum of 3 seconds and the label display to change every second.
Here is where I am with code....
How could I modify the following code to fit my criteria.
Private dt as DataTable
dt= Search(Surname) 'ASSUME SEARCH METHOD ALWAYS RETURNS A RESULT.
Me.GridViewTest.AutoGenerateColumns = False
Me.GridViewTest.DataSource = dt
I have the following which successfully changes the label
Private Sub Working()
While dt.rows.count < 1
Me.lblStatus.Text = "Searching, please wait..."
Me.lblStatus.Text = "Accessing database...."
Or if this code is too rubbish to even start with please provide your own example of how to do the same thing. Please for the example code, assume search method always returns a result of at least 1 record.
Your help would be much appreciated.