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

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());
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值