I have a small C# program that I created that contacts a web service and retrieves and processes datasets. No problem with that after some head scratching and much exploring of stackOverflow - thanks to all who contribute.
I normally work in the Linux world, so this is a rare foray into the Windows Environment. What I need to do is set it up so that TaskScheduler will run this application. There is no console display or interaction, everything is written to log files.
In Linux I would simply use a CRONTASK, but things are a bit different in Windows. Is this the ?proper? way to do this since it will be run once daily? I considered a windows service but there is a level of complexity that I am not sure is justified.
Thoughts?
The key difference between a process running as an app versus as a service is that the service can operate entirely outside the normal association with a user and session. Thus services can run such that they start before any user logs in and can continue running after users log off.
NET Windows apps that can run as console apps or as Windows Services. You can quickly hook up events such as your service Start and Stop events, configure using code e.g. to set the account it runs as, configure dependencies on other services, and configure how it recovers from errors.
A console application facilitates the reading and writing of characters from a console - either individually or as an entire line. It is the simplest form of a C# program and is typically invoked from the Windows command prompt.
If your app is doing small task every so often then a scheduled task is better as you'd be taking up system resources with a service sitting there doing nothing for most of the time.
If you're running your app on a recent version of windows then take a look in the control panel and search for "scheduled tasks". You will be able to set up a job to run your app daily in there.
you will probably script this, so use schtasks.exe to create your scheduled tasks: msdn link to schtasks.exe
also, on win7 and later, you can actually migrate the created scheduled tasks in form of xml and import them onto another machine, it's a little easier to manipulate and/or save them if you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With