Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my vb.net winform application, on click of start button the label1.text should be "process started" then some filesaving method will run after finish that method the label1.text should change to "file saved".

VB
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        
        lblStatus.ForeColor = Color.Red
        lblStatus.Text = "Saving to File"
         
         'Get the values and write to xls
                 Trigger()
                 SaveXls()
            
         lblStatus.Text = "File Saved"
         lblStatus.ForeColor = Color.Green


the initial status of label "saving to file" is not comingup. after the Trigger method finished, the status of the label is changing to "File saved"

Any suggestions please?
Posted

1 solution

Sounds like you need to research the BackgroundWorker[^] or other methods of multi-threading.

You need to put the Trigger and SaveXls methods on a separate thread so that you can update the current thread that is displaying the form and the label. You can find some CP articles[^] the could help you. This one[^] looks promising.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900