C backgroundworker progress bar not updating
The Button ‘Source Path’ displays all the files to copy in the List Box below ‘Source Path’ Text Block.When the user clicks on ‘Copy Files’ button, all the files will be copied in the List Box below ‘Target Path’ Text Block.and I will write my puny little test apps in WPF, even if they are just as ugly as my Windows Forms apps used to be.Now, I'm writing this cool little app and I want to do some interesting stuff in the background (my apps may be ugly, but at least they are responsive).Having something like await/async would help here, but even in that case the caller has to be aware of this (plus I need . So I came up with something that keep the sequential nature of the original call, doesn't affect the caller of the function makes the HTTP request but updates the UI.One of the most important things that differentiates a “quick and dirty” application from one that has been designed well is how the application’s user interface behaves during lengthy operations.Let's say that I have a method that makes an HTTP request that will take a long time to finish.
Note: All code samples presented here can be found in Code Plex, at threadsafepubsub.Let’s say that we just want to read a text file and return/display the number of lines found in the file.In this post, I’ll create a simple example of how you might use the Background Worker class to do some work on a background thread and keep your GUI responsive.We’ll start with a simple example that demonstrates how the GUI can become blocked and then evolve the application to make full use of the capabilities of the Background Worker class. We’ll have a File Reader class/object that reads text from a text file.WPF is still STA, which means you still have to be explicit about posting back to the main UI thread if your background thread needs to communicate updates …bummer, but I thought I knew how to program async from my Windows Forms apps.