How does Application.Run work?

  • (2 Pages)
  • +
  • 1
  • 2

29 Replies - 3332 Views - Last Post: 09 February 2011 - 10:50 AM Rate Topic: -----

#1 tigre_jose2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 08-February 11

How does Application.Run work?

Posted 08 February 2011 - 11:15 AM

Hi people, I'm kind of new in C# development, I would like to ask you, if someone know about how does the Application.Run works, I know the basic things, but I will like to know how does it works to try to emulate with my own code.

Regards
Is This A Good Question/Topic? 0
  • +

Replies To: How does Application.Run work?

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4536
  • View blog
  • Posts: 7,916
  • Joined: 08-June 10

Re: How does Application.Run work?

Posted 08 February 2011 - 11:22 AM

http://msdn.microsof...cation.run.aspx

Always check the MSDN first. It can usually help a lot.
Was This Post Helpful? 1
  • +
  • -

#3 tigre_jose2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 08-February 11

Re: How does Application.Run work?

Posted 08 February 2011 - 11:48 AM

I already read all MSDN, but the informacion showed in there isn't helpfull for what I want to do, I understand the basic functionality of the Application.Run, but I want the inside functionality, to try to understand better.

For example, I want to use, two Application.Run in my application, when one form is closed, one other form is opened and I use an Application.Run to do that, but in the second one doesn't have the functionality of the first, that's why I need to really know the inside functioanlity.
Was This Post Helpful? 0
  • +
  • -

#4 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: How does Application.Run work?

Posted 08 February 2011 - 12:05 PM

A Form has a Closing event.
http://msdn.microsof...(v=VS.100).aspx

Link is in spanish so you can understand it better.

Basically, when the Form1 fires the Closing event, open the other Form.

This post has been edited by Sergio Tapia: 08 February 2011 - 12:06 PM

Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1525
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: How does Application.Run work?

Posted 08 February 2011 - 12:06 PM

Why would you need to do that?
Was This Post Helpful? 0
  • +
  • -

#6 tigre_jose2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 08-February 11

Re: How does Application.Run work?

Posted 08 February 2011 - 12:09 PM

Because doing what I told you, the second Application.Run, doesn't stop in the second form I put.
The first form, is closed and it triggers the other one to open, but the other one just open and close at the instant, because the second Application.Run seems to don't stop.

I hope I explain well what my problem is.
Was This Post Helpful? 0
  • +
  • -

#7 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: How does Application.Run work?

Posted 08 February 2011 - 12:22 PM

Can you try sending me a private message in Spanish and I'll maybe translate a bit better?
Was This Post Helpful? 0
  • +
  • -

#8 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1525
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: How does Application.Run work?

Posted 08 February 2011 - 01:04 PM

View Posttigre_jose2, on 08 February 2011 - 03:09 PM, said:

Because doing what I told you, the second Application.Run, doesn't stop in the second form I put.
The first form, is closed and it triggers the other one to open, but the other one just open and close at the instant, because the second Application.Run seems to don't stop.

I hope I explain well what my problem is.


Thats because you can't close the opening form of an application. Closing the first form will close the application.

We normally handle this by hiding the first form when the second form opens.

Form2 f2 = new Form2();
f2.Open();
this.Hide();


Was This Post Helpful? 1
  • +
  • -

#9 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6081
  • View blog
  • Posts: 23,556
  • Joined: 23-August 08

Re: How does Application.Run work?

Posted 08 February 2011 - 01:33 PM

Why am I getting the feeling the OP is attempting to use Application.Run when he really wants to use the Process namespace?
Was This Post Helpful? 0
  • +
  • -

#10 tigre_jose2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 08-February 11

Re: How does Application.Run work?

Posted 08 February 2011 - 01:36 PM

What's the difference between the Application.Run and the Process Namespace?
Was This Post Helpful? 0
  • +
  • -

#11 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4536
  • View blog
  • Posts: 7,916
  • Joined: 08-June 10

Re: How does Application.Run work?

Posted 08 February 2011 - 01:39 PM

Actually, I don't think that's what he's trying to do here. He's probably just trying to chain forms.

View Posttigre_jose2, on 08 February 2011 - 02:36 PM, said:

What's the difference between the Application.Run and the Process Namespace?


Process isn't actually a namespace, it's a class inside the System.Diagnostics namespace. It's used for exactly what it sounds like: processes. Starting and manipulating processes.

Again, a quick trip to the MSDN would have helped there.

I don't think that's what you're trying to do. I think you're trying to open one form after the other closes. I think you should look into what the others have already mentioned.
Was This Post Helpful? 1
  • +
  • -

#12 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6081
  • View blog
  • Posts: 23,556
  • Joined: 23-August 08

Re: How does Application.Run work?

Posted 08 February 2011 - 01:42 PM

Yeah, I think you're right, . I just noted the form mention in one of the posts.
Was This Post Helpful? 0
  • +
  • -

#13 tigre_jose2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 08-February 11

Re: How does Application.Run work?

Posted 08 February 2011 - 01:42 PM

Yes, what I'm trying to do is to open a forma after another, but because how my app is designed, I can't use the basic code:

this.Close();
Form form = new Form();
form.Show();

Because all the logic isn't in the form code, is in another class that's handling all that, that's why I need the two Application.Run.
Was This Post Helpful? 0
  • +
  • -

#14 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4536
  • View blog
  • Posts: 7,916
  • Joined: 08-June 10

Re: How does Application.Run work?

Posted 08 February 2011 - 01:58 PM

Well, when you close the form that Application.Run took in, you exit the application. To avoid this, instead of closing the main form, .Hide() it instead, like eclipsed mentioned.

Look, pretend that your Program.cs file doesn't exist. This logic doesn't happen there. The entire Application logic exists in your main Form class.

So in that form class, you can do exactly what eclipsed mentioned further up the thread.

This post has been edited by insertAlias: 08 February 2011 - 02:00 PM

Was This Post Helpful? 0
  • +
  • -

#15 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6081
  • View blog
  • Posts: 23,556
  • Joined: 23-August 08

Re: How does Application.Run work?

Posted 08 February 2011 - 02:00 PM

Read some of the tutorials here so you can learn how to do this kind of thing properly.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2