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

Posted on 2009-05-07
Medium Priority
Last Modified: 2013-12-17

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?

Question by:techques
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
LVL 12

Expert Comment

ID: 24332947
Here's how to get a nice string of the time

returns the TimeSpane where you can check for a particular time
LVL 12

Expert Comment

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)

Author Comment

ID: 24332960
Can I  write

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

Accepted Solution

wht1986 earned 150 total points
ID: 24333014

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 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