David Marshal
David Marshal

Reputation: 43

C# - why this.Close(); dose not work for me?

iam not good at ENG so you will see some Incorrect spelling and bad grammar. and i am using Visual Studio 2015.

Hello. first of all iam new to programming.

well i got into some trouble with "this.Close();" and i need some help...

i am trying to simply close a loading form after the progress bar hits the value of 100 but it wont work.

here is the code:

 private void pbar_timer_Tick(object sender, EventArgs e)
    {
        progressBar1.Value += 10;

            if(progressBar1.Value==100)
        {
            pbar_timer.Stop();
            new main().ShowDialog();
            this.Close();

        }

    }

Well. i tried many ways but it wont work... the loading form will still hang in the screen and when the main form comes up it wont go.. :|

please help me if you know what should i do...

Thanks.

Upvotes: 0

Views: 70

Answers (1)

Trần Hoàn
Trần Hoàn

Reputation: 94

The ShowDialog() method block your current flow, until new "new main()" is closed. Use Show() instead.

Upvotes: 2

Related Questions