Well, it’s clear that you need to use return after Form.Close if you don’t want the rest of the method code to be executed. I mean sutiation like this:
private void SomeMethod()
{
if (someCondition)
{
Close();
return;
}
SomeOtherMethod;
}
But what if this SomeMethod is called from some other place or standart control event handler? Like Handler -> Method1 -> SomeMethod. If Close() is called from SomeMethod and then return is executed, will Method1 and Handler code be executed up to the end all right or will form be closed at last?
And is there any way to use Close to, well, close form immediately? I mean, just from this place, not before all the sequence will finish executing?
Just because your form is closed does not mean, that the process is stopped, so of course, the code will be executed.
If you don’t want to execute any other code after closing form inside of
SomeMethod, just rewrite your code, so thatSomeMethodwill returnfalsewhen there is no need to execute anything else.