当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > [译]Visual Basic 2005在语言上的增强(十)应用程序级别事件

ASP.NET
使用NUnit进行单元测试
[FxCop.设计规则]1. 抽象类不应该拥有构造函数
遍历XML文档返回二维数组(ASP)(更新版)
c#中的interface abstract与virtual
[VB.NET] Single & Double
asp.net验证码生成类(参考)
JAVA开发者应该去的20个英文网站 [摘]
C#中关于GDI+输出的问题
XML 命名空间提供了一种避免元素命名冲突的方法。
VS.NET 2005 Beta 2初体验(3)—操作SQL Mobile数据库
VS.NET 2005 Beta 2初体验(1)-用C#开发Managed代码
VS.NET 2005 Beta 2初体验(2)-用C++开发Native代码
VS.NET 2005 Beta2初体验(4)-Notification控件
XmlHttp异步获取网站数据的例子
利用C#编写一个简单的抓网页应用程序
C#中结构与类的区别
在.NET中实现彩色光标,动画光标和自定义光标
C#2.0新特性探究之模拟泛型和内置算法
C#2.0 新特性探究之委托与匿名委托
获取本机的本地上网IP地址

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 72 ::
收藏到网摘: n/a


另一个令你垂涎的新特性是这套崭新出炉的应用程序级别事件,你在一系列名为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.