Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Difference in showing forms

Difference in showing forms

Scheduled Pinned Locked Moved C#
question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kmuthuk
    wrote on last edited by
    #1

    Hi Anybody knows what is the difference between Application.Run(myForm) and myForm.Show()? Thanks in advance Muthu.

    L D 2 Replies Last reply
    0
    • K kmuthuk

      Hi Anybody knows what is the difference between Application.Run(myForm) and myForm.Show()? Thanks in advance Muthu.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Application.Run(form) runs a message loop, it only return when the form closes. :)

      Luc Pattyn

      1 Reply Last reply
      0
      • K kmuthuk

        Hi Anybody knows what is the difference between Application.Run(myForm) and myForm.Show()? Thanks in advance Muthu.

        D Offline
        D Offline
        Drew McGhie
        wrote on last edited by
        #3

        To Support what Luc said.

        Application.Run(myForm);
        MessageBox.Show("whee!");
        

        Would wait for your form to close to display "whee!", while

        myForm.Show()
        MessageBox.Show("whee!");
        

        Would open your form, then immediately show the messagebox. If I have child forms in windows applications I'm running, I generally use Form.Show() Form.ShowDialog() depending on what I need. ShowDialog acts similarly to Application.Run(), in that it must return before code is executed in the parent, while Show() allows for parallel interaction.

        R 1 Reply Last reply
        0
        • D Drew McGhie

          To Support what Luc said.

          Application.Run(myForm);
          MessageBox.Show("whee!");
          

          Would wait for your form to close to display "whee!", while

          myForm.Show()
          MessageBox.Show("whee!");
          

          Would open your form, then immediately show the messagebox. If I have child forms in windows applications I'm running, I generally use Form.Show() Form.ShowDialog() depending on what I need. ShowDialog acts similarly to Application.Run(), in that it must return before code is executed in the parent, while Show() allows for parallel interaction.

          R Offline
          R Offline
          Russell Jones
          wrote on last edited by
          #4

          I seem to remember that you can only have one message pump running per single threaded apartment. So Application.Run would bomb if a form was already loaded in the same apartment, whereas you could open as many form instances as you want with form.show() Russell

          D 1 Reply Last reply
          0
          • R Russell Jones

            I seem to remember that you can only have one message pump running per single threaded apartment. So Application.Run would bomb if a form was already loaded in the same apartment, whereas you could open as many form instances as you want with form.show() Russell

            D Offline
            D Offline
            Drew McGhie
            wrote on last edited by
            #5

            Ah, you're right. I was trying to give an example of something visual that the user would see.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups