rog_rickert
Member
- Joined
- Dec 17, 2020
- Messages
- 11
- Programming Experience
- Beginner
I have a question that feels like it should have a simple solution, but I'm having trouble figuring one out. I have a method in my application that contains a for loop. Inside the for loop a list of commands are run. The for loop is needed as each of these commands are run on a different channel (sending settings to a controller that has 4 output channels). I need the count for a progress bar that's located in another form. Here's a simplified view of the method to explain.
Hardcoding it in the example is easy as there's only 4 commands being executed, but there will be many more and some added at future dates by different people. I was hoping for a way to count these dynamically so that whoever changes the commands didn't have to count them and change the value by hand.
C#:
public void SendSettings()
{
byte i;
//Send all settings for channels
for (i = 1; i <= NUM_OF_CH; i++)
{
CmdSnd(OutModeSet, i, _Gvars.Channel[i].OutputMode);
CmdSnd(InvertModeSet, i, _Gvars.Channel[i].OutputInvertToggle);
CmdSnd(EnableModeSet, i, _Gvars.Channel[i].EnableMode);
CmdSnd(EnablePinPolaritySet, i, _Gvars.Channel[i].EnablePolarityPin);
ProgressValue += 4;
}
}
Hardcoding it in the example is easy as there's only 4 commands being executed, but there will be many more and some added at future dates by different people. I was hoping for a way to count these dynamically so that whoever changes the commands didn't have to count them and change the value by hand.