?
Solved

Windows Services

Posted on 2008-10-08
5
Medium Priority
?
207 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:VBdotnet2005
ID: 22675656
My second part of the question is above, "I want it to start at a certain time during the day" Is the possible?
0
 
LVL 14

Accepted Solution

by:
Binuth earned 500 total points
ID: 22675687
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
 

Author Comment

by:VBdotnet2005
ID: 22684031
what is TimeSpan(12 , 0 , 0) ? I have use timespan before.
0
 
LVL 14

Expert Comment

by:Binuth
ID: 22684201
>> what is TimeSpan(12 , 0 , 0) ?
just for comparing time
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question