1、新建一个Window类库项目,如下图所示:

window service 插件服务插件开发

 

2、添加插件接口引用:

window service 插件服务插件开发

 

3、引用命名空间

 

window service 插件服务插件开发

 

 

4、TimeLogPlug类实现接口IService

 

window service 插件服务插件开发

 

5、在类上加入属性定义:

window service 插件服务插件开发

 

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: }

相关文章:

  • 2021-11-18
  • 2021-08-10
  • 2021-06-13
  • 2021-04-17
  • 2021-04-16
  • 2021-11-18
  • 2021-11-18
  • 2021-10-17
猜你喜欢
  • 2021-03-30
  • 2021-11-18
  • 2021-09-29
  • 2021-11-21
  • 2021-11-30
  • 2021-12-18
  • 2021-12-18
  • 2021-11-18
相关资源
相似解决方案