Click here to Skip to main content
15,891,717 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have created a class library in my project which scans a series of files. In my main project which uses this DLL as a reference, I'd like to create a progress bar which shows how many file have been scanned so far.

The dll class makes use of a foreach loop since it's purpose is to turn each file into a hash code. The foreach loop has been used to join each converted segment of a file together so that I can have a 512 bit long code, and then it proceeds to the next file.

I have defined a variable in the dll class which is -->
public static int value_ = 0;
This variable is updated at the the end of the foreach loop.

Now in my main project, I'd like to use this variable to update my progress bar at the same time the function in my class library project is running.

For example :

DLL.function();
pb.value = value_;

I'd appreciate any hint on how I can implement this.
Posted
Comments
Sergey Alexandrovich Kryukov 8-May-13 16:47pm    
Would you make it a formal answer?
—SA
Maciej Los 8-May-13 16:49pm    
Yes, i do. And i done it now ;)

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-May-13 17:35pm    
Well, a 5. :-)
—SA
Maciej Los 9-May-13 14:30pm    
Thank you, Sergey ;)
Did anyone suggest you multithreading yet? :-)
"Safe, Simple Multithreading in Windows Forms, Part 1"[^].
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-May-13 17:35pm    
Sure, a 5.
—SA
1. Run your DLL.function() on a separate thread.

2. Have the DLL.function() fire an event every time a foreach loop has completed and increment the value.

3. Have you main project listen for this event. Every time the event is triggered update your progress bar. You can pass the value for the progress bar inside the event parameters.
 
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