1. Why are you using the Console.WriteLine in a GUI based app?
2. I think it would be better to use events in C# and delegate the notification to the parent Form instead of hardcoding/eyeballing the form to be closed before your proceed in C# code.
Handling and Raising Events | Microsoft Docs[
^]\
This way you can trigger the event in the parent Form that the form is closing and the parent Form will "know" the form has closed, so you can proceed from there. Please check the documentation to learn more about that.
A little dirty approach will be to pass the parent Form instance in the test Form constructor and just before closing, call the method in parent Form to notify that the form has closed.
WindowForm1 form1;
public test(GridModel gridModel, WindowForm1 parent)
{
InitializeComponent();
this.form1 = parent;
}
private void Window_Closed(object sender, EventArgs e)
{
IsClosed = true;
Console.WriteLine( " Ok " +IsClosed);
form1.FormClosed(this);
}
For this to work, accept the method in WindowForm1 to proceed;
public void FormClosed(test form) {
}
I repeat,
this is a dirty approach; what's worse is that if you call the method this way, your secondary form has not yet closed (the method call has not returned) so you will be incorrect in your logic;
I am sorry. :sigh: