I'm not understanding why and I don't find any resources explaining clearly where the issue should be, when I try to recall a method (not a function). I'm asking for specific help or code, not some general conceptual advice, I would need some actual help to understand how to achieve what I need, if I don't get a practical example I suppose I'll never understand.
I have a method following a bunch of instructions and when I reach some point I have a check/statement: if the condition is met -> restart the whole code of this method.
From what I read online it should be easy as that but it actually doesn't work.
The first approach was inside the Click event of a Button, so in the check condition part it was just
What happens is just the instruction seems to be ignored although it gets read (tried to debug with breakpoints).
I also tried with an if-else statement, like
I also tried to use different instructions like
or
but none worked. I also tried moving the full code in a private void, so the button would call the void method and so would do the method as well, but not even that worked. Can someone give a piece of advice to understand how this works or why it doesn't? It seems total nonsense to me it's so difficult to perform such a basic instruction.
I have a method following a bunch of instructions and when I reach some point I have a check/statement: if the condition is met -> restart the whole code of this method.
From what I read online it should be easy as that but it actually doesn't work.
The first approach was inside the Click event of a Button, so in the check condition part it was just
C#:
if (condition) { button1.PerformClick();
I also tried with an if-else statement, like
C#:
if (condition) { button1.PerformClick(); } else { go on with the remaining part }
C#:
button1.Invoke(new Action(() => { button1.PerformClick(); }));
C#:
button1_Click(button1, EventArgs.Empty);