-1

How to display an intermediate screen in the transition from screen 1 to screen 2

Screen 2 contains a table with a database that takes some time to display. Switching between screen 1 and screen 2 The software disappears until Screen 2 opens. How can I post a message to the user "Please wait ..."

this my code:

this.Hide();
Form C = new Main();
C.ShowDialog();
this.Show();

i work on C# , WinForm

thanks

Gold
  • 60,526
  • 100
  • 215
  • 315
  • 2
    Possible duplicate of [How do I show a "Loading . . . please wait" message in Winforms for a long loading form?](https://stackoverflow.com/questions/1918158/how-do-i-show-a-loading-please-wait-message-in-winforms-for-a-long-loadi) – mjwills Dec 05 '18 at 20:25

1 Answers1

-2

You can use Thread. Start your Thread before ShowDialog and run below-shown method within that thread. To close that thread you need to use Thread Form's Shown Event. So that you can close thread after form successfully shown to the user. It is mandatory to close your thread.

    private static LoadingForm loadForm;

    static private void ShowForm()
    {
        loadForm = new LoadingForm();
        Application.Run(loadForm);
    }

This loadForm object should have your loading image in the background-image property of form.

I am showing minimal code so that you can do rest of the task by yourself. It's good if you do something by yourself. Beware of how to handle cross-thread exception whenever using Thread.

Hope this makes help.

Manish Jain
  • 1,197
  • 1
  • 11
  • 32