在启动屏幕之前执行代码
我有一个 VB.NET 应用程序,选中了启用应用程序框架
,并设置了启动屏幕
。同时,我需要在加载启动屏幕之前运行一些代码。 MyApplication_Startup
好像去得比较晚,所以不适合。我知道可以使用自定义启动屏幕,但更喜欢任何其他方式来实现它,而无需更复杂的自定义。
编辑:显然,问题是不同的。在启动屏幕之前运行的代码是特定于线程的。它没有产生适当的效果,因为启动屏幕位于另一个线程上。
I have a VB.NET application with Enable application framework
checked, and Splash screen
set. At the same time, I need to run some code before the splash screen is loaded. MyApplication_Startup
seems to go later, so it's not suitable. I understand it's possible with custom splash screen, but would prefer any other way to make it without more complex customization.
EDIT: Apparently, the issue is different. Code that runs before the splash-screen is thread-specific. It doesn't take proper effect, since splash screen is on another thread.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在项目属性下,单击查看应用程序事件。然后阅读评论:'以下事件可用于 MyApplication:
'
' 启动:在创建启动表单之前,应用程序启动时引发。
' 关闭:在所有申请表关闭后引发。如果应用程序异常终止,则不会引发此事件。
' UnhandledException:如果应用程序遇到未处理的异常,则引发该异常。
' StartupNextInstance:启动单实例应用程序且该应用程序已处于活动状态时引发。
' NetworkAvailabilityChanged:当网络连接连接或断开时引发。
不知道oyu有没有经历过这个。
Under project properties click View Application Events. Then read the comment: ' The following events are available for MyApplication:
'
' Startup: Raised when the application starts, before the startup form is created.
' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
I don't know if oyu have been through this yet.
您是否使用 F8 键单步执行过代码?在显示启动屏幕之前,调试器可以向您显示可以在何处添加代码。
Have you stepped through your code using the F8 key? The debugger can show you where you can add code before your splash screen is shown.