Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to BackGroundWorker change label.text
Message
From
16/12/2010 22:28:19
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01492852
Message ID:
01493019
Views:
48
In this time, i very grateful your reply first....

the C# code is not work in vb.net
------------------------------------------------------
And i again try you give me code, in this time, is ok la, the label text and progress bar can change in same time, hahaha..... i post my code
But also has another problem come..... i think write the useful function, one time pass the aaa("update the masterfile", 10) string and integer
it is because i have more more words and integer to display in BeginInvoke....
the AddressOf < the complier say can not pass the value to aaa(), and i use the fuction also can not , so i can not understand it to write la...
more more time display word and function to write....
 Private Sub buttonYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonYes.Click

        BackgroundWorker1.RunWorkerAsync()  
       End Sub
 
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

        Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)
       todo_work(worker, e) 
       
   End Sub

Private Sub todo_work(ByVal worker As BackgroundWorker, ByVal e As DoWorkEventArgs)

        update()
end sub

 Private Function update()

     ...... sql statement.....

       If Label1.InvokeRequired Then
                Label1.BeginInvoke(New MethodInvoker(AddressOf aaa)                              < first time
            Else
                Label1.Text = "update the masterfile"
            End If

...... sql statement.....

       If Label1.InvokeRequired Then
                Label1.BeginInvoke(New MethodInvoker(AddressOf bbb)                         < second time
            Else
                Label1.Text = "update the itemfile"
            End If

...... sql statement.....

       If Label1.InvokeRequired Then
                Label1.BeginInvoke(New MethodInvoker(AddressOf ccc)                      <  third time
            Else
                Label1.Text = "complete update the masterfile"
            End If

...... sql statement.....

       If Label1.InvokeRequired Then
                Label1.BeginInvoke(New MethodInvoker(AddressOf ddd)                 <  fourth time
            Else
                Label1.Text = "complete update the itemfile"
            End If


end sub

 Private Sub aaa()                                                                                        < wirte first  function time
   
        Labelupdate.Text = "update the masterfile""        
        Me.ProgressBar1.Value = 10
    End Sub

 Private Sub bbb()                                                                                        < wirte second function time
   
        Labelupdate.Text = "update the itemfile""
        Me.ProgressBar1.Value = 20
    End Sub

 Private Sub ccc()                                                                                           < wirte third function time
   
        Labelupdate.Text = "complete update the masterfile""
        Me.ProgressBar1.Value = 30
    End Sub

 Private Sub ddd()                                                                                              < wirte fourth function time
   
        Labelupdate.Text = "complete update the itemfile""
        Me.ProgressBar1.Value = 100
    End Sub
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform