public partial class ImportaDados : ServiceBase
{
private StreamWriter ws = new StreamWriter("C:\\temp\\LogImportacao.log", true, Encoding.ASCII);
private DataTable dt = new DataTable();
private System.Timers.Timer timer1;
public ImportaDados()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
ws.WriteLine(DateTime.Now + " Iniciando Servido...");
ws.Close();
timer1 = new System.Timers.Timer(5000);
timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.OnElapsedTime);
timer1.Enabled=true;
}
protected override void OnStop()
{
ws.WriteLine(DateTime.Now + " Parado Servido...");
ws.Close();
timer1.Enabled = false;
}
private void OnElapsedTime(Object source, System.Timers.ElapsedEventArgs e)
{
ws.WriteLine(DateTime.Now + "Servido Rodando...");
ws.Close();
}
}
Alguem me ajude pf, onde estar o erro ai que nao funciona o timer ?