Solved

How to set time and call web service in C# windows service program?

Posted on 2009-05-07
4
696 Views
Last Modified: 2013-12-17
Hi

I have a windows service program which has a timer.

The timer needs to check the time everyday.

If (System.Time == 14:00)
{
// call a web service
}

But, I just found System.DateTime, but no Time.

How should I code it?


0
Comment
Question by:techques
  • 3
4 Comments
 
LVL 12

Expert Comment

by:wht1986
ID: 24332947
Here's how to get a nice string of the time
DateTime.Now.ToShortTimeString()

Otherwise
DateTime.Now.TimeOfDay
returns the TimeSpane where you can check for a particular time
0
 
LVL 12

Expert Comment

by:wht1986
ID: 24332952
Sorry posted to quick, based on your example above I would use
            TimeSpan target = new TimeSpan(14, 0, 0);
            if (DateTime.Now.TimeOfDay == target)
            {
            }
0
 

Author Comment

by:techques
ID: 24332960
Can I  write

if(System.DateTime.Now.Hour == 14)
{
}
0
 
LVL 12

Accepted Solution

by:
wht1986 earned 50 total points
ID: 24333014
yup
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Receiving a string from a WebService Push 21 47
Vb. Net application freezes 9 45
Capture logon name 13 73
vb.net winforms sizing/resolution? 4 32
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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