C backgroundworker progress bar not updating
Here in this example we are creating xml of 1000 records using the Backgroundworker know as threading and in parallel we are showing the progress bar control to show as the process progresses. NET Framework 2.0 Background Worker class makes it easy to code simple threading into your applications.Notice that we tell it that we want to have it report progress and support cancellation. Here’s the code: In this routine, the progress bar and the listbox are updated with values from the worker thread.
By default, Progress Bars let you display a value within the range from zero to one hundred. The properties of a Background Worker which you need to know are: Worker Reports Progress – Used to indicate Progress when a task is running. The Progress Changed event is raised from the Do Work Event using using System;using System. Cancelled is set to true and the block of code in it executed, The cancellation of Task is Sent from the Do Work Event to the Run Worker Completed Event. Here we gets the User State and add the data to the data Grid View1 and we set the tool Strip Progress Bar1 value to the progress percentage of the background task that is sent as paramter in Report Progress() Method in Do Work Event. Actual execution of the Thread Starts here Next, we Report the progress using the Report Progress Method of the Background Worker where we pass it a int variable i and Retrive Table Data Obj which has the record number and the Obj contains the value of the record that is read recently.