Windows Services

How can I create Windows Services in Vb.net?  Instead of a windows form pops up all the time, I want it to start at a certain time during the day.
VBdotnet2005Asked:
Who is Participating?
 
BinuthConnect With a Mentor Commented:
yes you can, set timer control and check with current time
like...

public partial class TestServise : ServiceBase
{
	private System.Threading.Timer TimerTest = null;
 
	public TestServise()
	{
		InitializeComponent();
		this.TimerTest = new System.Threading.Timer(Timer_Elapsed , null , System.Threading.Timeout.Infinite , System.Threading.Timeout.Infinite);
	}
 
	protected override void OnStart(string[] args)
	{
		try
		{
			// set timer intervale
			this.TimerTest.Change(5000 , 5000);
		}
		catch (Exception Ex)
		{
			this.Stop();
		}
		finally
		{
 
		}
	}
 
	private void Timer_Elapsed(object sender)
	{
		try
		{
			// check your time
			if (DateTime.Now.TimeOfDay = new TimeSpan(12 , 0 , 0))
			{
				// do your action
			}
		}
		catch (Exception Ex)
		{
		}
	}
 
 
}

Open in new window

0
 
VBdotnet2005Author Commented:
My second part of the question is above, "I want it to start at a certain time during the day" Is the possible?
0
 
VBdotnet2005Author Commented:
what is TimeSpan(12 , 0 , 0) ? I have use timespan before.
0
 
BinuthCommented:
>> what is TimeSpan(12 , 0 , 0) ?
just for comparing time
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.