Sabtu, 28 September 2013

Difference between Application.Run() and form.showDialog() method in windows form

class program {
  static void Main() {
    Form form = new Form();
    form.ShowDialog();
  }
}

This code would show a blank form and wait for the user to close it before returning control to the Main function, but it's not the code you will generally be writing. Instead, to make it accessible in other parts of your application, you'll be designating one form as the main form. To do this, pass the main form as an argument to the Run method of the Application object, which also resides in the System.Windows.Forms namespace

class program {
  static void Main() {
    Form form = new Form();
    Application.Run(form);
  }
}

The Application class's static Run method will show the main form, and when it's closed, Run will return, letting our Main function exit and closing the process.


Tidak ada komentar:

Posting Komentar