Requirement – I have a periodic task I want to run in a Windows environment for my application. It will have a simple interface that allow some basic configuration (for example, URLs and how often to run it). I want it to run every X hours (configurable) when the machine is running.
Question – Do I just create an application with a system tray presence for this? Or should I be creating a service that has a separate UI that hooks into it.
BY THE WAY – I’m a beginner C# developing using Visual Studio Express, keep in mind. Also if you could give a quick overview of the design of what you recommend that would be great for someone new to this (for example, if you suggest a service, does this mean you really need one application for the service, and another application that has a UI that does the configuration for the service?)
I developed such an application last year. A simple windows forms application that has just a tray icon. The user is able to configure the application through a context menu (shown when the user right-clicks the tray icon). I used a timer that fires the Elapsed event…
If this application will be the only doing some tasks on timely basis then go just with a windows forms app with a tray icon. But if there will be several possible application that can send input and trigger some activity then you should consider moving the common functionality in a windows service. You should also consider using a windows service if the application will be running on a machine with Terminal services (multiple users -> multiple instances of your app).
I wouldn’t use a Scheduled Task! It’s less user friendly…
-Pavel Nikolov