Relationship between the "InitializeComponent ();" method and loading a "Splash Screen"

1

I've added a splash screen to a project in the simplest way, that is, by changing the Build Action property to SplashScreen . Although with very similar visual effects, what actually happens when we compare these two solutions?

A

public MainWindow()
{
    InitializeComponent();
    Thread.Sleep(5000);
}

B

public MainWindow()
{
    Thread.Sleep(5000);
    InitializeComponent();
}
    
asked by anonymous 12.04.2016 / 10:12

1 answer

0

In this case, it's important that you know what's going on in the InitializeComponent() method. It is responsible for creating, adding, and positioning all components on the screen.

So what's the difference between the A and the B solution?

In the A solution, the components are created and given a% 5 seconds% after all components have been created .

In B solution, first a% of 5 seconds is given, and only after that time passes will the components be created.

It's worth mentioning that Sleep() hangs the graphical interface, if you're using .NET Framework 4.5 or later you can test Sleep() .

More information in this answer

    
12.04.2016 / 14:21