L
L
littleguga2015-02-06 21:25:52
C++ / C#
littleguga, 2015-02-06 21:25:52

How to continue executing code after the form is displayed?

I figured out the difference between ShowDialog() and Show().
You need to call the window using the Show() method, but you need to continue executing the code after the Shown event.

deleteWaiting waitForm = new deleteWaiting();
this.Enabled = false;
waitForm.Owner = this;
waitForm.Show();
//здесь проверка показана ли форма?
Thread.Sleep(12350);
MessageBox.Show("test");

Tried creating isShown variable in deleteWaiting form. And then put if / while with a check for this variable. But this did not lead to success.
The called form has the character of a graphical stub and transferring the necessary code to it on the Shown event is not an option, you will have to drag too much behind you.
Thanks in advance for your reply. If I'm wrong somewhere, etc. - I beg you to correct me, as I am just starting to work with c #.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Silin, 2015-02-06
@littleguga

Alternatively, you can use the Shown event itself, just subscribe to it from the first form:

private void button1_Click(object sender, EventArgs e)
        {
            var form = new Form1();
            form.Shown += form_Shown;
            form.Show();

        }

        void form_Shown(object sender, EventArgs e)
        {
            MessageBox.Show("Test");
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question