SoloEnLan/SoloEnLan/Service1.cs

49 lines
1.3 KiB
C#

using SoloEnLan.model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using SoloEnLan.service;
namespace SoloEnLan
{
public partial class SoloEnLan : ServiceBase
{
monitor m;
private string nombreService = "SoloEnLan";
public SoloEnLan()
{
InitializeComponent();
if(!EventLog.SourceExists(nombreService))
{
EventLog.CreateEventSource(nombreService,"Application");
}
logService.EventLog = eventLog1;
eventLog1.Source = nombreService;
eventLog1.Log = "Application";
m =new monitor();
}
public void inicia()
{
m.start();
}
protected override void OnStart(string[] args)
{
logService.log("Se inicia " + nombreService);
//eventLog1.WriteEntry("Se inicia " + nombreService);
inicia();
}
protected override void OnStop()
{
m.fin();
logService.log("Finaliza" + nombreService);
}
}
}