Solved

Windows Services

Posted on 2008-10-08
5
198 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 125 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 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