Link to home
Start Free TrialLog in
Avatar of zensolutions
zensolutionsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Scheduled Windows Form Application or Console Application with GUI

I need to create an application that runs daily (mon-fri) as a schedule.  

I could do this as a console application but the settings for the app need to be in a friendly GUI format and there are a number of other issues that would require a GUI i.e I need to produce reports showing exceptions and processed data, also previous runs and their results in tabular form that can be sorted by clicking the header column.

You also need to be able to run a process manually if the schedule failed.

I thought of having a console application for the process and then a GUI application for the other bits.  Is there a more efficient way where all code resides in one project.

Thanks

Lee
Avatar of wguerram
wguerram

You could create Projects libraries, that will hold the GUI part.
Avatar of zensolutions

ASKER

Could you elaborate on how this would work and how to actually code it please?  I am new to C# .NET.
ASKER CERTIFIED SOLUTION
Avatar of Marcus Keustermans
Marcus Keustermans
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i read somewhere that for a task that needs to be run at a specific time daily that it is better to run as a scheduled task and not a windows service.  I felt that the windows service would be a good way of implementing the solution but then when I read that I started looking at the scheduled task method.  Do you have any ideas of how to do this in a windows service?
It is faily simple to do this in a windows service.

You create a windows service that contains a timer that runs code every so often. then you have a config file that you use to set the time when the specific logic is suposed to be run i.e the schedule.

In the timer elapsed event you compare the current time to the time in your config file and run the logic if the time matches the scheduled time criteria. On completion you can set a flag in the registry to indicate that the scheduled task ran correctly.  

You logic should then contain code that checks the registry for the task completed flag as well.  If the flag was not set due to some issue then you can run it again.

Your logic flow should be as follows

Check if task was completed by querying the registry.
If not compare the times
if the current time is equal or bigger to the scheduled time then run the task
If the task completes without errors then set the regstry flag

it would wise to set a window in which you want the task to run.  Let say you want to run a task at 5PM then you should give it a window to run in if it does not complete the first time. Lets say the window is 2 hours.  Then the task will attempt to execute between 5PM and 7PM until it ran succesfully.

I hop this makes sense to you.
I read a bit more about the windows service and after looking through a number of fors and against decided to go with the one solution with multiple projects.  Thanks for your time.  I may be back when I get to the next stages of deveolpment with more questions.