views:

136

answers:

5

We have an unattended app w/o a user interface that is is periodically run.

It is a VB.NET app. Instead of it being developed as a service, or a formless Windows application, it was developed with a form and all the code was placed in the form_load logic, with an "END" statement as the last line of code to terminate the program.

Other than producing a program that uses unneeded Windows form resources, is there a compelling reason to send this code back for rework to be changed to put the start up logic in a MAIN sub of a BAS file?

If the program is to enter and exit the mix (as opposed to running continuously) is there any point in making it a service?

If the app is developed with a Form do I have to worry about a dialog box being presented that no one will respond to even if there are no MessageBox commands in the app?

I recall there used to be something in VB6 where you could check an app as running unattended, presumably to avoid dialogs.

+3  A: 

I don't know whether there are conditions where this will not run.

However, if the code was delivered by someone you will work with going forward, I would look at this as an opportunity to help them understand best practices (which this is not), and to help them understand that you expect best-practice code to be delivered.

Eric J.
+1  A: 

If you don't want it to be a service, nothing says that it has to be a windows service. Scheduling it to run via the Task Scheduler or something similar is a valid option.

However, it does sound like the developer should have choose a "Console App" project, instead of a "Windows Forms" project to create this app.

slolife
+2  A: 

First of all, you don't need it to be run in a Form. Forms are there for Presentation, so it should not be done there.

If you don't want to mess with converting the application a Service (not difficult, but not very easy neither), you shoud create a Console Application, and then, schedule it with Windows Task Scheduler.

This way, you create a Console Application, with a Main function, that does exactly what you need.

Anyway, the programmer could show windows, so there should not be any messagebox. Any communication should be done via Logging to: local files, windows events, database.

If you want more information on any of them, ask me.

Luis Lobo Borobia
What is the reason why you suggest changing it to a console app? besides having less overhead, does this also negate the possibility of a dialog box being presented, a problem associated with a WinForm app? Changing it to a console app also was a gut instinct I was considering
Velika
First of all, the application will be simpler, less code.No "events". Nothing more than the logic you need to implement.Second, you also should remove any Imports to any namespace that you are not going to use, like Forms.Windows.If I were to do your application, I would do it as a Service, and I would schedule the processes inside using Quartz.NET (http://quartznet.sourceforge.net/) I would do Logging with Log4NET (http://logging.apache.org/log4net/index.html)Of course, all this depends on the requirements. What is your application about? What does it do? Database?
Luis Lobo Borobia
A: 

Send it back. The application is bulkier and slower than it needs to be, although that won't be much of an issue. It is somewhat more likely to run out of resources. But the main reason: converting it to a console app is very easy.

reinierpost
A: 

If you don't prefer for the Console window to popup, simply do the following.

Create a new class "Program.vb", add a public shared Main() method, and move the "OnLoad" logic from the form to this method.

Next delete the form, and change the project start up object (Available in the project properties window) to use the Program.Main instead of the Form.

This will have the same effect, without the windows forms resources being used. You can then remove the references to System.Windows.Form and System.Drawing.

Tom Anderson