Solved

Windows Services

Posted on 2008-10-08
5
153 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
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:Binuth
Comment Utility
0
 

Author Comment

by:VBdotnet2005
Comment Utility
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 125 total points
Comment Utility
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
Comment Utility
what is TimeSpan(12 , 0 , 0) ? I have use timespan before.
0
 
LVL 14

Expert Comment

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now