You will notice that you are unable to click the button to show the message box. A Progress Bar control that will illustrate the progress of the long running task. It's shown when the long running process begins and is hidden again when the process has ended or is canceled.using System; using System. A control to assist with this is the progressbar control. If you execute a long running task, you usually want to let your users know about the progress of the task. It also turns out that things are still not as widely document. For starters, there's the handy Dispatcher on every UIElement which provides the Begin Invoke method to run code on the right thread.
This is extremely problematic and makes for a poor user experience. The pupose of this control is to illustrate the responsiveness of the user interface during the long running process. We'll take a look at another example that will bring all of these concepts together to illustrate executing a long running task on a seperate thread with a progress bar that updates the user interface via the Dispatcher object. The main window contains the following controls; A List Box control that will hold random values that are generated during the long running process. However, there are a few concerns that you must be aware of if you plan to access values on the UI thread from the worker thread. So by using the dispatcher object from the user interface code you are able to access the user interface controls from your worker thread. Multithreading is a complex topic and is beyond the scope of this article. The Dispatcher object has the Begin Invoke method which will execute an asynchronous delegate on the thread in which the dispatcher object was created.
Have you ever had to execute a bit of code that took an extremely long time to complete?