盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

使用JScript.NET创建asp.net页面(5)

时间:2025/1/12作者:未知来源:盾怪网教程人气:

[摘要]Jscript.net可以用JScript 或任意NET 框架语言(如 C #,VB7.0) 通过增加extends主题词在类声明以后来继承和扩展现有类。这能力允许Jscript.net非常容易地利...
Jscript.net可以用JScript 或任意NET 框架语言(如 C #,VB7.0) 通过增加extends主题词在类声明以后来继承和扩展现有类。这能力允许Jscript.net非常容易地利用 NET 平台的丰厚资源。为了说明这些,给出一个程序。这个程序扩展了NET 框架的ServiceBase 类。
// 导入需要的.net命名空间
import System;
import System.ServiceProcess;
import System.Diagnostics;
import System.Timers;
class SimpleService extends ServiceBase
{
   private var timer : Timer;
   function SimpleService()
   {
      CanPauseAndContinue = true;
      ServiceName = "JScript Service";
      timer = new Timer();
      timer.Interval = 1000;
      timer.AddOnTimer(OnTimer);
   }
   protected override function OnStart(args : String[])
   {
      EventLog.WriteEntry("JScript Service started");
      timer.Enabled = true;
   }
   protected override function OnStop()
   {
      EventLog.WriteEntry("JScript Service stopped");
      timer.Enabled = false;
   }
   protected override function OnPause()
   {
      EventLog.WriteEntry("JScript Service paused");
      timer.Enabled = false;
   }
   protected override function OnContinue()
   {
      EventLog.WriteEntry("JScript Service continued");
      timer.Enabled = true;
   }
   function OnTimer(source : Object, e : EventArgs)
   {
      EventLog.WriteEntry("Hello World from JScript!");
   }
}
ServiceBase.Run(new SimpleService());




关键词:运用JScript.NET创建asp.net页面(5)




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版