Hello guys. I have 2 Windows Forms. Let's say, the first form is like a intro ... ( you know, when you enter in C#, a green window appears for some seconds ). Ok, i use a timer, and after 10 seconds from starting the application, i try to close the first form ( the intro/credits form ), and I open the 2nd form. Ok, it works ... but when i close the 2nd form, the program dissaper, but in Task Manager, it still appears ( the first form - the intro/credits form). That's not a big problem, but i want like, after that 10 seconds, to dissapear and from Task Manager.

I use this: this.Close();

6 Years
Discussion Span
Last Post by Mitja Bonca

Ok, lets define, you have Form1 and Form2. Form1 is Main Form, Form2 is Info.

Which one you call in Program.cs (Application.Run(XXXX)); - xxxx is from1 or form2?

This is how you should have:
in application.Run method you have to call Form1 (so the main form, not the intro). Before the form shows, you call Form2 with a timer (when timer comes, form1 closes as well and then opens form1.

There is another way, even better - this is the use of keyword "using" arround the application.start.
The code would look like:

//Form1 (Main Form):
        static void Main()
            using (Form2 form2 = new Form2())
                if (form2.ShowDialog() == DialogResult.OK)
                    Application.Run(new Form1());

//Form2 (Info):
public partial class Form2 : Form
        Timer timer1;
        public Form2()
            timer1 = new Timer();
            timer1.Interval = 10000;
            timer1.Tick += new EventHandler(timer1_Tick);

        private void timer1_Tick(object sender, EventArgs e)
            DialogResult = DialogResult.OK;

Simple and useful - I hope you like it.

bye, bye

Votes + Comments
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.