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();

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()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            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()
        {
            InitializeComponent();
            timer1 = new Timer();
            timer1.Interval = 10000;
            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Stop();
            DialogResult = DialogResult.OK;
        }
    }

Simple and useful - I hope you like it.

bye, bye
Mitja

commented: thanks +1

It worked. Thank you very much !

You are welcome :)
I`m glad you like it.

bye,
Mitja

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.