I´m programming an installer that installs new software and so on and, in addition, I want to read some hardware stuff like CPU architecture and so on. But this takes a while, so I want to display a splash screen while the program reads the hardware. But it won´t display and I don´t know why.
Can someone help me, please?
In the Header of the Mainclass I create a new Thread
:
public Hauptfenster()
{
InitializeComponent();
t = new Thread(new ThreadStart(ZeigeLadeBildschirm));
t.Start();
}
When the Thread
starts the SplashScreen should be displayed and the hardware should be read by the Mainclass. So the method "ZeigeBildschirm" says:
public void ZeigeLadeBildschirm()
{
SplashScreen sp = new SplashScreen();
sp.Show();
createFolder();
entpacken();
Verionszahlalsd();
GetHardwareInformationRAM();
GetOSInformation();
GetReleaseDateBIOS();
GetLastBootTime();
GetHardwareInfoVideo();
GetHardwareInfoMonitor();
GetSystemInfo();
GetCDDriveInformation();
GetDiskDriveInformation();
GetHardwareInfoCPU();
GetInstallDateWindows();
}
to stop the Mainthread while the new Thread
reads out the hardware I coded this after creation of the Thread
in the Header:
while (t.IsAlive)
{
}
So the Header looks like this:
public Hauptfenster()
{
InitializeComponent();
Initialisierung();
t = new Thread(new ThreadStart(ZeigeLadeBildschirm));
t.Start();
while (t.IsAlive)
{
}
GetAdditionRAMInfo();
SchreibeDaten();
}
But when I start the program, the hardware is read out but no SplashScreen is displayed on the screen. After the hardware reading code is finished, the MainForm opens and shows all data. How can I fix that code, so that the SplashScreen
will be displayed, the hardware will be read out and the SplashScreen
disappears and the MeinForm will be displayed?
Code of SplashScreen
:
namespace The5thBlueskyInstallerSplashScreen
{
public partial class SplashScreen : Form
{
public SplashScreen()
{
InitializeComponent();
}
}
}