What is the difference between Show (), ShowDialog () and Application.Run ()?

4

I read something about modal but I did not understand, could anyone explain?

    
asked by anonymous 28.05.2017 / 12:57

1 answer

3

Let's start at the beginning, Application.Run() . This is the static method that starts running the entire windows system of the application. This is where the framework takes care of the application and starts calling your code as it is necessary.

It is common to pass the first form that should be opened. It only calls it without passing a form if the form or forms were created before.

The Show() can only be used on a form object, and it will cause the form to be shown. Whenever it is not shown on the screen you must use Hide() , or Close() that closes the form, and obviously it will no longer be shown.

A normal form is a cooperative component with the application, you can click anywhere else on it, you can continue to have interaction.

ShowDialog() is a special form that is opened and blocks user interaction with the application other than itself, until the form is closed. It should only be used in special circumstances where you really can not let the user do other things until he resolves what is in this form. It can only be called from within a normal form.

Note that the application can continue running normal without user interaction through threads .

    
28.05.2017 / 14:14