1、新建一个Window类库项目,如下图所示:
2、添加插件接口引用:
3、引用命名空间
4、TimeLogPlug类实现接口IService
5、在类上加入属性定义:
6、完整实现类如下:
using System;
using System.Collections.Generic;
using System.Text;
4:
using WindowServices.Interface;
using System.ComponentModel;
7:
namespace TimeLog
9: {
)]
)]
)]
13: [Serializable]
class TimeLogPlug:IService
15: {
private ServiceEntity _serviceEntity;
bool _isRuning;
void Initialize(ServiceEntity serviceEntity)
19: {
20: _serviceEntity = serviceEntity;
21: }
22:
void Pause()
24: {
25: }
26:
void Start()
28: {
true;
))
31: {
, _serviceEntity.Name);
33: }
while (_isRuning)
35: {
))
37: {
,DateTime.Now);
39: }
40: System.Threading.Thread.Sleep(10000);
41: }
42: }
43:
void Stop()
45: {
false;
47: }
48: }
49: }