Hi,
I ran into a problem that I just cannot figure out.
I have a windows application with a main form, on which a user control is added dynamically when a device connects trough USB.
On a user control, there is a thread wich is getting data from the device trough USB and when it is finished, I want to change a progressbar that is located on the main windows form where user control reside.
This is the code that is I call on the user control thread to change the progress bar value:
and this is a code that is called on the main form:
but the progress bar does not change!
Any help would be greatly appreciated!
Thanks
Greg
I ran into a problem that I just cannot figure out.
I have a windows application with a main form, on which a user control is added dynamically when a device connects trough USB.
On a user control, there is a thread wich is getting data from the device trough USB and when it is finished, I want to change a progressbar that is located on the main windows form where user control reside.
This is the code that is I call on the user control thread to change the progress bar value:
VB.NET:
Frm_Main.UpdateProgressBar(CInt((AllBytesReceived / MaxBytesInFlash) * 100))
and this is a code that is called on the main form:
VB.NET:
Private Delegate Sub UpdateProgressBarDelegate(ByVal value As Integer)
Dim _UpdateProgressBarDelegate As New UpdateProgressBarDelegate(AddressOf UpdateProgressBar)
Public Sub UpdateProgressBar(ByVal value As Integer)
If Me.ProgressBar1.InvokeRequired Then
Invoke(_UpdateProgressBarDelegate, value)
Else
If value <= 100 Then
If Me.ProgressBar1.Value <> value Then
Me.ProgressBar1.Value = value
If value = 100 Then
Me.BtnDownloadData.Text = "Download Data"
End If
End If
End If
End If
End Sub
but the progress bar does not change!
Any help would be greatly appreciated!
Thanks
Greg