1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
public partial class AutoShare : ServiceBase
{
private Timer _timer = new Timer();
public AutoShare()
{
InitializeComponent();
AutoLog = true;
ServiceName = "AutoShare";
eventLog1.Source = "AutoShare";
_timer.Tick += new EventHandler(timer_Tick);
_timer.Interval = 1000;
}
public static void Main()
{
Run(new AutoShare());
}
protected override void OnStart(string[] args)
{
AutoShareCheck.Execute(eventLog1); // est exécuté
_timer.Start();
}
protected override void OnStop()
{
_timer.Stop();
}
private void timer_Tick(object sender, EventArgs e)
{
AutoShareCheck.Execute(eventLog1); // n'est jamais exécuté
}
} |
Partager