Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 C# C#4.0
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 8-May-13 10:59am
Comments
Sergey Alexandrovich Kryukov at 8-May-13 16:47pm
   
Would you make it a formal answer?
—SA
Maciej Los at 8-May-13 16:49pm
   
Yes, i do. And i done it now ;)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
Sergey Alexandrovich Kryukov at 8-May-13 17:35pm
   
Well, a 5. :-)
—SA
Maciej Los at 9-May-13 14:30pm
   
Thank you, Sergey ;)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Did anyone suggest you multithreading yet? Smile | :)
"Safe, Simple Multithreading in Windows Forms, Part 1"[^].
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 8-May-13 17:35pm
   
Sure, a 5.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 8 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100