我正在编写安装新软件的安装程序等等,此外,我想阅读一些硬件内容,如CPU架构等等。但这需要一段时间,所以我想在程序读取硬件时显示启动画面。但它不会显示,我不知道为什么。
有人可以帮助我吗?
在主要类的标题中,我创建了一个新的objdump -d -M intel so.o | c++filt
:
so.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <pure>:
0: 48 89 7c 24 f0 mov QWORD PTR [rsp-0x10],rdi
5: c5 fb 12 44 24 f0 vmovddup xmm0,QWORD PTR [rsp-0x10]
b: c3 ret
c: 0f 1f 40 00 nop DWORD PTR [rax+0x0]
0000000000000010 <pretty(long long)>:
10: 48 89 7c 24 f0 mov QWORD PTR [rsp-0x10],rdi
15: c5 fb 12 44 24 f0 vmovddup xmm0,QWORD PTR [rsp-0x10]
1b: c3 ret
1c: 0f 1f 40 00 nop DWORD PTR [rax+0x0]
0000000000000020 <wrap(long long)>:
20: 48 89 7c 24 f0 mov QWORD PTR [rsp-0x10],rdi
25: c5 fb 12 44 24 f0 vmovddup xmm0,QWORD PTR [rsp-0x10]
2b: c3 ret
2c: 0f 1f 40 00 nop DWORD PTR [rax+0x0]
0000000000000030 <add1(long long __vector(2), long long)>:
30: c5 f8 28 c8 vmovaps xmm1,xmm0
34: 48 83 ec 08 sub rsp,0x8
38: e8 00 00 00 00 call 3d <add1(long long __vector(2), long long)+0xd>
3d: 48 83 c4 08 add rsp,0x8
41: c5 f9 d4 c1 vpaddq xmm0,xmm0,xmm1
45: c3 ret
46: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[rax+rax*1+0x0]
4d: 00 00 00
0000000000000050 <add2(long long __vector(2), long long)>:
50: c5 f8 28 c8 vmovaps xmm1,xmm0
54: 48 83 ec 08 sub rsp,0x8
58: e8 00 00 00 00 call 5d <add2(long long __vector(2), long long)+0xd>
5d: 48 83 c4 08 add rsp,0x8
61: c5 f9 d4 c1 vpaddq xmm0,xmm0,xmm1
65: c3 ret
66: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[rax+rax*1+0x0]
6d: 00 00 00
0000000000000070 <add3(long long __vector(2), long long)>:
70: 48 83 ec 18 sub rsp,0x18
74: c5 f8 29 04 24 vmovaps XMMWORD PTR [rsp],xmm0
79: e8 00 00 00 00 call 7e <add3(long long __vector(2), long long)+0xe>
7e: c5 f9 d4 04 24 vpaddq xmm0,xmm0,XMMWORD PTR [rsp]
83: 48 83 c4 18 add rsp,0x18
87: c3 ret
当Thread
启动时,应显示SplashScreen,并且Mainclass应读取硬件。所以方法“ZeigeBildschirm”说:
public Hauptfenster()
{
InitializeComponent();
t = new Thread(new ThreadStart(ZeigeLadeBildschirm));
t.Start();
}
在新的Thread
读出标题后创建public void ZeigeLadeBildschirm()
{
SplashScreen sp = new SplashScreen();
sp.Show();
createFolder();
entpacken();
Verionszahlalsd();
GetHardwareInformationRAM();
GetOSInformation();
GetReleaseDateBIOS();
GetLastBootTime();
GetHardwareInfoVideo();
GetHardwareInfoMonitor();
GetSystemInfo();
GetCDDriveInformation();
GetDiskDriveInformation();
GetHardwareInfoCPU();
GetInstallDateWindows();
}
后编码的硬件时停止Mainthread:
Thread
所以Header看起来像这样:
Thread
但是当我启动程序时,硬件被读出但屏幕上没有显示SplashScreen。硬件读取代码完成后,MainForm将打开并显示所有数据。如何修复该代码,以便显示while (t.IsAlive)
{
}
,硬件将被读出并且public Hauptfenster()
{
InitializeComponent();
Initialisierung();
t = new Thread(new ThreadStart(ZeigeLadeBildschirm));
t.Start();
while (t.IsAlive)
{
}
GetAdditionRAMInfo();
SchreibeDaten();
}
消失并显示MeinForm?
SplashScreen
代码:
SplashScreen
答案 0 :(得分:1)
您需要在主线程上执行所有UI。
在额外线程完成之后,在创建线程之前,将启动画面创建和显示转移到主类,然后从主线程关闭它。
最好使用事件,但是,根据我在评论中的建议使用DoEvents
,最小(未经测试)的更改将是:
public Hauptfenster()
{
InitializeComponent();
Initialisierung();
SplashScreen sp = new SplashScreen();
sp.Show();
t = new Thread(new ThreadStart(ZeigeLadeBildschirm));
t.Start();
while (t.IsAlive)
{
System.Windows.Forms.Application.DoEvents();
System.Windows.Forms.Application.DoEvents();
Thread.Sleep(55);
}
GetAdditionRAMInfo();
SchreibeDaten();
sp.Close();
}
删除另一个帖子中的sp
引用。