国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 北安市| 缙云县| 马公市| 玛沁县| 武川县| 河津市| 容城县| 丹巴县| 长岭县| 尼玛县| 泸水县| 黄龙县| 西城区| 青海省| 金秀| 兴城市| 洮南市| 云龙县| 溧阳市| 康保县| 茂名市| 密山市| 浠水县| 布尔津县| 玛沁县| 玛纳斯县| 旅游| 安龙县| 行唐县| 洮南市| 枝江市| 资兴市| 双城市| 株洲市| 昌图县| 大冶市| 垦利县| 阳曲县| 平度市| 正镶白旗| 通河县|