【发布时间】:2016-02-27 05:29:36
【问题描述】:
所以我正在创建一个应用程序,该应用程序将具有一个加载资源的启动屏幕,完成后将加载应用程序的主窗体。在过去,我只是让启动屏幕拥有线程并保持隐藏状态,但我正在玩弄实际上让我的主窗体成为线程所有者的想法,但我在窗体之间转换时遇到了麻烦。我目前的做法是
void main(String[] args)
{
ApplicationContext appContext = new ApplicationContext(new SplashScreen());
appContext.ThreadExit += appContext_ThreadExit;
Application.Run(appContext);
}
place
private void appContext_ThreadExit(object sender, EventArgs e)
{
Application.Run(new MainForm());
}
这给了我一个错误,即您无法在线程上启动新的消息循环。那么我该如何正确执行这个过渡呢?还是我已经通过允许 SplashScreen 拥有线程来使用最佳方法?
【问题讨论】:
-
为什么不使用异步?让启动画面使用 async/await 加载资源
-
更多代码不会有帮助吗?你只是显示有限的代码集