In this post, I’ll create a simple example of how you might use the BackgroundWorker class to do some work on a background thread and keep your GUI responsive. A Simple Example of Using the BackgroundWorker Class You no longer have to worry about cross-threading exceptions and checking a control’s InvokeRequired property. NET 2.0, doing work on a background thread has become a lot easier, with the introduction of the BackgroundWorker class. The problem with this is that the GUI will freeze up while the application does whatever work it needs to do.Ī well designed application, on the other hand, is one that is careful to do as much work as possible in background threads, keeping the GUI responsive and making sure that it makes it obvious to the user that work is going on in the background and adjusts the GUI to disallow any user actions that don’t apply until after the work finishes. The quick-and-dirty approach is to just do all of your work in a button’s Click event handler and not worry about the user interface. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |