[译]Visual Basic 2005在语言上的增强(十)应用程序级别事件

王朝c#·作者佚名  2006-12-17
窄屏简体版  字體: |||超大  

另一个令你垂涎的新特性是这套崭新出炉的应用程序级别事件,你在一系列名为MyApplication的部分类中可以找到它。你可以在解决方案资源管理器中查找My Project项目中的一个名为MyEvents.vb的文件。你也同样可以点击Application面板上的View Code按键,然后在代码编辑器中查看它。

这些新的应用程序级别事件类似于ASP.NET应用程序中global.asax文件里的应用程序事件。共暴露了五个事件:

· Shutdown

· Startup

· StartupNextInstance

· NetworkAvailabilityChanged

· UnhandledException

当应用程序启动或关闭时,前三个事件被引发。当机器网络状态发生变化时,NetworkAvailabilityChanged事件被引发。为了防止系统抛出一个你在其他地方未曾处理的异常,你还可以在UnhandledException事件下添加代码。

@以下是原文供大家参考@

Application Level Events

Another new feature you'll want to take advantage of is a new set of Application-level events available in a partial class named MyApplication. Look for a file named MyEvents.vb under the My Project item in Solution Explorer. You can also find this file behind the View Code button on the Application tab in the application designer.

These new Application-level events are similar to the application events in the global.asax file in an ASP.NET application. Five events are exposed:

• Shutdown

• Startup

• StartupNextInstance

• NetworkAvailabilityChanged

• UnhandledException

The first three events are fired as the application starts up and shuts down. NetworkAvailabilityChanged fires when the network state changes on the machine. Put code in the UnhandledException event in case an exception is thrown that you don't handle anywhere else.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航