Using C#, I have list of methods (Actions). I then have a method to invoke action using a foreach loop. A button click calls the method which in turn invokes every action in the list in one go. What I am after is for the click to only execute one action per click. Thanks in advance.
private static List<Action> listOfMethods= new List<Action>();
listOfMethods.Add(() => method1());
listOfMethods.Add(() => method2());
listOfMethods.Add(() => method3());
//====================================================================
private void invokeActions()
{
foreach (Action step in listOfMethods)
{
step.Invoke();
//I want a break here, only to continue the next time the button is clicked
}
}
//====================================================================
private void buttonTest_Click(object sender, EventArgs e)
{
invokeActions();
}