Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top