using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Data.SqlClient;
namespace TestService
{
public partial class Wind_Service : ServiceBase
{
public Wind_Service()
{
InitializeComponent();
}
public System.Threading.Timer stateTimer;
public TimerCallback delegateTimer;
SqlConnection con = new SqlConnection("MultipleActiveResultSets=True;Server=" + ".\\SQLEXPRESS;DataBase=db;Integrated Security=SSPI;");
SqlCommand cmd;
SqlDataAdapter adp = new SqlDataAdapter();
#region On Service Start
protected override void OnStart(string[] args)
{
delegateTimer = new TimerCallback(performAction);
stateTimer = new Timer(delegateTimer, null, 0, (1000 * 60 * 1)); //One second = 1000 miliseconds)
EventLog.WriteEntry("Service Exactly Started at : " + DateTime.Now.ToString());
}
#endregion
#region Body of the Code
public void performAction(object sender)
{
try
{
//Body of the code
}
catch (Exception ex)
{
EventLog.WriteEntry("Service having error : " + ex.Message);
}
}
#endregion
#region On Service Stop
protected override void OnStop()
{
EventLog.WriteEntry("Service Stopped Successfully at : " + DateTime.Now.ToString());
}
#endregion
}
}
Monday, February 9, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment