How to update progressBar from another class
-
I dont see any error in your previous code other than two declaration of the delegates ProgressChangeHandler. is C_Comm.cs is defined in a common dll? can you give some more input about the project files where these .cs files are added. If it was me, I keep all the common implementations/interfaces in a shared dll and refer these dll in different projects rather keeping same .cs files each project. what are you trying to do here with this 'cb.ProgressChanged != null' checking for null right??
Jibesh V P
C_Comm.cs is a separate VS project, separate dll, commonly referenced by everything (CR5.cs, PC.cs). Do you think I still need everything except the delegate part in my iCR? The CR5 implements iCR and that's the only way I can see getting the ProgressChanged defined in CR5 from PC.cs, but when I take out the delegate part, I get "The type or namespace name 'ProgressChangeHandler' could not be found (are you missing a using directive or an assembly reference?)". I can't keep my iCR.cs and C_Comm.cs in the same dll because of the whole layout. The VS project layout is: Project 1 has iCR.cs Project 2 has PC.cs and a couple of other things. (update - this has form with progress bar) Project 3 has CR5 (implements iCR) and a couple of other things. Project 4 has CR_Factory which will return a CR5 through the iCR interface to my PC.cs Project 5 has C_Comm.cs. It is referenced in PC.cs, CR5, and iCR. In the future I'll have a CR6 project like the CR5. As far as cb.ProgressChanged != null, I'm just trying to get what you suggested originally to work with my delegate in my C_Comm. Yes, checking for null before I send the update.
-
C_Comm.cs is a separate VS project, separate dll, commonly referenced by everything (CR5.cs, PC.cs). Do you think I still need everything except the delegate part in my iCR? The CR5 implements iCR and that's the only way I can see getting the ProgressChanged defined in CR5 from PC.cs, but when I take out the delegate part, I get "The type or namespace name 'ProgressChangeHandler' could not be found (are you missing a using directive or an assembly reference?)". I can't keep my iCR.cs and C_Comm.cs in the same dll because of the whole layout. The VS project layout is: Project 1 has iCR.cs Project 2 has PC.cs and a couple of other things. (update - this has form with progress bar) Project 3 has CR5 (implements iCR) and a couple of other things. Project 4 has CR_Factory which will return a CR5 through the iCR interface to my PC.cs Project 5 has C_Comm.cs. It is referenced in PC.cs, CR5, and iCR. In the future I'll have a CR6 project like the CR5. As far as cb.ProgressChanged != null, I'm just trying to get what you suggested originally to work with my delegate in my C_Comm. Yes, checking for null before I send the update.
-
I can't reference CR5 in iCR because that would be an incorrect implementation for factory design pattern. Plus, CR5 is an iCR and if iCR referenced CR5, it would be circular.
I wound up leaving the original delegate in my iCR and everything you originally recommended above. Then I created a separate delegate and handler in my C_Comm.cs class. I couldn't see any other way to update my progressBar and also share the same delegate and event. Thanks for the help!
-
I wound up leaving the original delegate in my iCR and everything you originally recommended above. Then I created a separate delegate and handler in my C_Comm.cs class. I couldn't see any other way to update my progressBar and also share the same delegate and event. Thanks for the help!
I dont see any error in your declaration, i.e the delegate method is declared in Comm.cs file which is referred in all the other 3(or more project) iCR,CR5 and form Class. so the delegate should be available in all other classes and you need to include the proper namespaces in other project files.
Jibesh V P
-
I dont see any error in your declaration, i.e the delegate method is declared in Comm.cs file which is referred in all the other 3(or more project) iCR,CR5 and form Class. so the delegate should be available in all other classes and you need to include the proper namespaces in other project files.
Jibesh V P
Thank you so much for the help. We have a very small work group here, and they are not programmers and don't understand this stuff (not to mention me having a tough time with events and this architecture). It turned out I wasn't "using" C_Comm in my interface. Once I did that and fixed a couple of declarations to use the C_Comm version of the Handler, all worked. :)
-
Thank you so much for the help. We have a very small work group here, and they are not programmers and don't understand this stuff (not to mention me having a tough time with events and this architecture). It turned out I wasn't "using" C_Comm in my interface. Once I did that and fixed a couple of declarations to use the C_Comm version of the Handler, all worked. :)
-
@jibesh - I added an interface (see my recent question), and my event is null when I try to update my progress bar. I know you have a good idea about events and interfaces. If you could take a look at my newly posted question(Thursday post maybe), I'd appreciate it. Thanks!