Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have written a program that is running a thread to prevent lockup of my form1 while performing the tasks. I have created a progress bar on my form1 but I am having lots of trouble figuring out how to update that progress bar from my thread, which runs in a separate class.

Does anyone know a good reference?
Posted

Create an Event for the class and use Thread to raise the event.

The event will send back the progressvalue. So inside the handler you need to reset the progress value.

Make sure you invoke the progress value from UI Thread.

Multiple Thread Progress Bar Control[^]
 
Share this answer
 
Abhishek's answer is correct.

You could also use a BackgroundWorker. It's DoWork event is raised on a seperate thread and the ReportProgress method automatically raises the ProgressChanged event on the UI thread.

Example here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900