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

ASP.NET
asp.net 使用Silverlight操作ASPNETDB数据库
ASP.NET 前后台调用方法
ASP.NET中等安全模式的一些经验分享
asp.net 打印控件使用方法
网站开发技术:ASP.NET 2.0搭建网站
ASP.NET实例教程:创建数据透视表
ASP.NET 4进行SEO优化提高网站排名和权重
ASP.NET实例教程:订阅 GeoRSS 订阅源
ASP.NET页面间数据传递的9种方法
ASP.NET教程:网页表单多个按钮完成不同功能
Asp.net的服务器推技术 (Server Push)
asp.net 无刷新附件上传实现方法
ASP.NET 定制简单的错误处理页面实现代码
c# 在WebBrowser中用SendMessage模拟鼠标点击
asp.net 表单验证新思路
.NET从优酷专辑中采集所有视频及信息(VB.NET代码)
VS2005 水晶报表在时部署时遇到的问题
ASP.NET 输出图片简单代码
一天精通asp.net的学习经验小结
DataGridView中绑定DataTable数据及相关操作实现代码

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


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