中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > .NET > 临时文章
[译]Visual Basic 2005在语言上的增强(十)应用程序级别事件
作者:未知 时间:2005-07-27 21:31 出处:CSDN 责编:chinaitpower
              摘要:[译]Visual Basic 2005在语言上的增强(十)应用程序级别事件

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


关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有