If you use multithreading to improve the performance of your Windows Forms applications, you must make sure that you make calls to your controls in a thread-safe way.
It is important to make sure that access to your controls is performed in a thread-safe way.
It is unsafe to call a control from a thread other than the one that created the control without using the Invoke method.
Step 1: Add a Progress Bar control to the Form1 and set its Dock property to Bottom so that it is docked to the bottom edge of the form.
Step 2: To show progress of a process we need to set a range using Minimum and Maximum property of the Progress Bar.
But the default value of the Maximum property is 100 which we will change and set it to the number of records in our table.
To show the progress on the Progress Bar we have to set the Value property. Progress Percentage to the Value property so that we can see increasing progress on the Progress Bar for every record fetched from the database.To change your settings, choose Import and Export Settings on the Tools menu.For more information, see Customizing Development Settings in Visual Studio.private void set Text Unsafe Btn_Click( object sender, Event Args e) // This method is executed on the worker thread and makes // an unsafe call on the Text Box control.private void Thread Proc Unsafe() ' This event handler creates a thread that calls a ' Windows Forms control in an unsafe way.The Minimum is the value of when the Progress Bar is completely empty and Maximum is the value of when the Progress Bar is completely filled.