您的位置:首页 > 编程语言 > ASP

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

2008-04-24 03:42 330 查看
ET 框架语言(如 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());
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: