The form does not close after the form is called. Close

We have an application running on a client that exhibits strange behavior. At random times during the day, the OK button (which calls the Form.Close method) on certain forms will not close the form. By this, I mean that the user clicks a button and displays in the trace that Form.Close has been called, but the form will not be closed.

The strange thing is that the form itself still responds, so they can click any button on the form, and the code behind the buttons will be executed, but the form simply will not be closed.

This condition lasts from a few seconds to several minutes. Then, suddenly, the form begins to move away and disappear. Really strange.

So, to repeat, the following will happen:

  • Form.ShowDialog() → Form displays
  • The user works with form buttons and clicks, etc.
  • Form.Close() called → User clicked the close button
  • A time passes when the form simply waits for closing, while still being responsive (during this time, a disappointed user several times forgot the close button without an answer).
  • Suddenly the form is placed, and the result of the dialogue comes back from Form.ShowDialog

Notes:

  • I do not use threads like threading.
  • At certain points in time, it is reported that the process explorer.exestopped on the PC, can this affect the behavior of the form? We are planning a recreation of the PC.

My question is, does anyone know of a scenario that might trigger the behavior described above?

, , , Form.Close, , , Close, , .

, explorer.exe ?

.

***

, , .

+4
3

# form.Close() ?

- this.Close() line?

:

private void OKButton_Click(object sender, EventArgs e)
{
    this.Close();

    somecodehere <-- is there any code here? (after this.Close)
}

Form.Close , , , , , , , .

0

, hide , , .

Form.Hide();
Form.Close();

, , - . , . .

0

@zdimension, :

  • , , , -
  • , Close(), , - .
  • , - FormClosing .
  • Check if any other Click event response has been added for the close button.

These things can help you find if something goes wrong, but I don’t think the problem is what you are doing after calling Close (), because you are saying that the form is still responding.

0
source

Source: https://habr.com/ru/post/1623724/


All Articles