Wednesday, April 7, 2010

Why WPF ProgressBar is not updating

When you put a loop and try to update the ProgressBar from that loop, it will not update the visual.The visual will update only after the execution of the you can’t see the incremental animation.Here is the solution for that issue.

Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
End Sub
Sub IncrementContinuously()
For i = 0 To 50
prgs.Dispatcher.Invoke(New CrossAppDomainDelegate(AddressOf IncrementBy1), DispatcherPriority.Background, Nothing)
End Sub
Sub IncrementBy1()
prgs.Value = prgs.Value + 1
End Sub

This link contains some more solutions.

1 comment:

  1. Thank you. That's definitely the simplest way to achieve this annoying threading task.