G
Guest
Hello
I am trying to update a Progress bar on a form. I am able to update it via using a simple clock timer, but as soon as I perform a long operation G1 (generation of a report) in a separate form, it stops updating it, but keeps on incrementing the Progress bar values in the background and displays the updated Pbar after finishing the operation G1.
My requirement is that it should update during the execution of operation G1.
On further exploration I have come to know that if I put updation of Pbar on a separate thread and use some queuing and dequeing, it would work. I have done that but behaviour remains the same. Can you Please point out where I am going wrong. I am new to Threading and Queuing.
I am attaching a part of my code. I have seen the following thread and queue are working as I have traced the flow. I may be wrong in refreshing the PBar as I have tried PBar.refresh, PBar.update after updating PBar.Value.
Dim sq as New Queu
CTimer_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs)
Tr
sField = Format(Now, "ss"
If sField = "00" The
PBar0.Value =
Els
PBar0.Value = CInt(sField
End I
PBar0.Increment(1
sq.Enqueue(PBar0.Value
End Try
Private Sub b1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b1.Clic
Dim sT As New System.Threading.Thread(AddressOf UpdateBar
sT.Start(
End Su
Private Sub UpdateBar(
Tr
D
System.Threading.Thread.CurrentThread.Sleep(2500
If sq.Count > 0 The
PBar0.Value = sq.Dequeu
'PBar0.Update(
'PBar0.Refresh(
End I
Loo
End Tr
End Sub
I am trying to update a Progress bar on a form. I am able to update it via using a simple clock timer, but as soon as I perform a long operation G1 (generation of a report) in a separate form, it stops updating it, but keeps on incrementing the Progress bar values in the background and displays the updated Pbar after finishing the operation G1.
My requirement is that it should update during the execution of operation G1.
On further exploration I have come to know that if I put updation of Pbar on a separate thread and use some queuing and dequeing, it would work. I have done that but behaviour remains the same. Can you Please point out where I am going wrong. I am new to Threading and Queuing.
I am attaching a part of my code. I have seen the following thread and queue are working as I have traced the flow. I may be wrong in refreshing the PBar as I have tried PBar.refresh, PBar.update after updating PBar.Value.
Dim sq as New Queu
CTimer_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs)
Tr
sField = Format(Now, "ss"
If sField = "00" The
PBar0.Value =
Els
PBar0.Value = CInt(sField
End I
PBar0.Increment(1
sq.Enqueue(PBar0.Value
End Try
Private Sub b1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b1.Clic
Dim sT As New System.Threading.Thread(AddressOf UpdateBar
sT.Start(
End Su
Private Sub UpdateBar(
Tr
D
System.Threading.Thread.CurrentThread.Sleep(2500
If sq.Count > 0 The
PBar0.Value = sq.Dequeu
'PBar0.Update(
'PBar0.Refresh(
End I
Loo
End Tr
End Sub