Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-05-07
4
Medium Priority
?
721 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
[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
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 150 total points
ID: 24333014
yup
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

609 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