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

ASP.NET
DVNEWS 3.2 1013版免虚拟目录的安装方法,只要三个步骤
DataRow的序列化问题
VB.net基础:使用UDP发送和接收消息
采用HttpModules来重写URLs(实践篇)
要用到事务了
DataGrid中单元格的比较
动态引用WebService,建立WebService虚拟机
[初学VB.NET]数据绑定
使用ASP调用WebService时不能以Name为数据库中的字段
在VB.NET里操作文本文件
web下打印的办法
怎样把SQL_SERVER数据库里的(类型是image)图片显示在aspx页面里的image控件里
C#中字符串的加密
中小企业信息应用的利器:DAP-Dynamic Applications Platform
数据库系统概论学习笔记
体会到译者的艰辛,也发现了他们犯的错误
IISManager V1.1 是一个在线管理IIS,维护站点组件,安全稳定,最重要的是完全免费。
VS FlexGridPro 8.0如何在window98运行---有没有升级版本,急请高手指点
给立方体添加纹理
Wrox的C#高级编程第三版第一部分第一章(1~9页)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 66 ::
收藏到网摘: 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.