1

I'm coding a console application that is reading and writing some stuff at different intervals during the day. I want this later (if its "final") as a service. For now a simple console application is better (that's how I thought) because its easier to use and I can see the result without having to register/start/end the service. Is it easy to later, if I'm done with the testing, just create a new service project and copy the code from the console application?

I heard now that we should not use Timer in a service. But I'm using System.Threading.Timer in my console application a lot. Does it mean that I'll be in trouble? Is it this "testing on console app and then using it on service" thing not a good idea? Any suggestions?

MaxDataSol
  • 358
  • 1
  • 2
  • 18
miri
  • 1,611
  • 5
  • 20
  • 24
  • Where did you hear that you should not use `Timer` in your service? – Dan Puzey Aug 23 '12 at 10:39
  • @DanPuzey"If you're writing a Windows Service that runs a timer, you should re-evaluate your solution." - in this thrad(http://stackoverflow.com/questions/246697/windows-service-and-timer) Will did post that. – miri Aug 23 '12 at 11:16

3 Answers3

1

You can create Windows service and Right click->Properties and change Output Type as Console Application do your developement.Once you have done with development change back Output Type as Windows Application.

Take a look at this link to know deep about the both timers.

Hukam
  • 1,016
  • 18
  • 40
0

The problem with System.Threading.Timer is that there's no easy way to start/stop the timer. And because of that, you can't realiably use it for tasks which could possibly take LONGER than the timer interval.

Switch to System.Timers.Timer instead:

http://netpl.blogspot.com/2010/05/systemwindowsformstimer-vs.html

Wiktor Zychla
  • 47,367
  • 6
  • 74
  • 106
0

A good solution for you - is to try Application As Service software

You can launch every application as a service.

DarunTim
  • 1
  • 1