国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

create and Control Windows Services--Not a Slap Sh

2024-07-21 02:21:28
字體:
供稿:網(wǎng)友
not a slap shot, but almost as fast
creating the service using .net is fairly straightforward. you use the .net framework's system.serviceprocess namespace and four classes within it: servicebase, serviceinstaller, serviceprocessinstaller, and servicecontroller. these classes provide most of the functionality you need to create a service (see figure 1).

   
figure 1 | everything you need in one namespace. click here.


the servicebase class defines methods a derived class can override so the service control manager can control a service—including onstart(), onstop(), onpause(), and oncontinue(). furthermore, a service can override the oncustomcommand() function to carry out specific operations sent to it programmatically by an external service controller (more on this later). implementing these functions in your derived class gives you the necessary structure of a service:

protected override void onstart(string[] args)
{
}
protected override void onstop()
{
}
protected override void onpause()
{
}
protected override void oncontinue()
{
}
allow your service to begin execution by defining an entry point into your executable, as you would with a regular executable. within the main() function, create an instance of your class and call the run() method defined by the servicebase base class. if you want your executable to support multiple services, create an array of servicebase objects with each element corresponding to one of your defined services:

static void main()
{
system.serviceprocess.servicebase[] myservices;

myservices = new system.serviceprocess.servicebase[] { new service1, new service2() };

system.serviceprocess.servicebase.run(myservices);
}
note that run() does not start your service. in other words, you won't receive an onstart() call from the run() method itself. as i mentioned before, the service control manager controls the service by calling the necessary controlling functions.
國(guó)內(nèi)最大的酷站演示中心!
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 德化县| 通道| 宁乡县| 乐业县| 凯里市| 五家渠市| 梅州市| 炉霍县| 克什克腾旗| 韩城市| 八宿县| 宜君县| 鲜城| 小金县| 石屏县| 碌曲县| 清流县| 锦州市| 堆龙德庆县| 修水县| 桐柏县| 新源县| 黄陵县| 禄丰县| 中山市| 喀喇沁旗| 安达市| 津南区| 霞浦县| 丰县| 白沙| 象州县| 临猗县| 安达市| 嘉义县| 巢湖市| 新巴尔虎左旗| 柳江县| 威宁| 侯马市| 德清县|