468,780 Members | 2,259 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,780 developers. It's quick & easy.

What's the Best Startup Scenario for Unattended Server Execution?

I'm a long-time VB6 programmer in a shop that is mostly moving to VB
..NET 2005. And I'm confused about coding the start of solutions for
unattended operations.

Much of what I write is old-time batch. Such programs are started from
a scheduler and run on a server, cycling through a mass of data,
without human intervention. No form should show on the server monitor,
although an invisible one may be needed to support the Winsock or other
control.

In VB6, I usually have a Main routine in a standard module as the
startup. But in a VB 2005 Windows Application, the startup has to be a
form, even if you don't have any intrinsic need for one.

I briefly looked into console applications, but never need a DOS-type
window. And console applications seem out of the question because they
require giving up ApplicationEvents.

Code like this does work to turn a Windows Application into what I am
used to:

Public Class MyUselessForm
Private Sub MyUselessForm_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
Main()
End Sub
Sub Main()
' do the real processing starting from here
End
End Sub
End Class

However, there must be something slicker. Before I start using the
above many times, does someone have a better idea? And, no, going back
to COBOL won't be better :-)

Steve Eisenberg Pennsylvania U.S.A.

Jun 14 '06 #1
3 1404
CT
Steve,

You don't actually have to set a Form in a Windows application to be the
startup object. In the properties for a project, you can set the startup
object to be Sub Main and place that in a Module. In VS 2005, you need to
clear the Enable application framework checkbox to select Sub Main in the
Startup object list.

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
<st********@yahoo.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
I'm a long-time VB6 programmer in a shop that is mostly moving to VB
.NET 2005. And I'm confused about coding the start of solutions for
unattended operations.

Much of what I write is old-time batch. Such programs are started from
a scheduler and run on a server, cycling through a mass of data,
without human intervention. No form should show on the server monitor,
although an invisible one may be needed to support the Winsock or other
control.

In VB6, I usually have a Main routine in a standard module as the
startup. But in a VB 2005 Windows Application, the startup has to be a
form, even if you don't have any intrinsic need for one.

I briefly looked into console applications, but never need a DOS-type
window. And console applications seem out of the question because they
require giving up ApplicationEvents.

Code like this does work to turn a Windows Application into what I am
used to:

Public Class MyUselessForm
Private Sub MyUselessForm_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
Main()
End Sub
Sub Main()
' do the real processing starting from here
End
End Sub
End Class

However, there must be something slicker. Before I start using the
above many times, does someone have a better idea? And, no, going back
to COBOL won't be better :-)

Steve Eisenberg Pennsylvania U.S.A.

Jun 15 '06 #2
Steve,

In addition to Carsten, Jay has somewhere in this newsgroup once showed all
the possibilities to start-up a VBNet application. It are definitely more
than that "one" in Cobol (I thought eleven).

Be aware that although Carsten writes it completely correct, we probably all
had problems finding that the first time for version 2005 (it is easier in
2002/2003), so don't hesitate to reply if you do not find it or that it does
not work.

:-)

Cor

<st********@yahoo.com> schreef in bericht
news:11*********************@i40g2000cwc.googlegro ups.com...
I'm a long-time VB6 programmer in a shop that is mostly moving to VB
.NET 2005. And I'm confused about coding the start of solutions for
unattended operations.

Much of what I write is old-time batch. Such programs are started from
a scheduler and run on a server, cycling through a mass of data,
without human intervention. No form should show on the server monitor,
although an invisible one may be needed to support the Winsock or other
control.

In VB6, I usually have a Main routine in a standard module as the
startup. But in a VB 2005 Windows Application, the startup has to be a
form, even if you don't have any intrinsic need for one.

I briefly looked into console applications, but never need a DOS-type
window. And console applications seem out of the question because they
require giving up ApplicationEvents.

Code like this does work to turn a Windows Application into what I am
used to:

Public Class MyUselessForm
Private Sub MyUselessForm_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
Main()
End Sub
Sub Main()
' do the real processing starting from here
End
End Sub
End Class

However, there must be something slicker. Before I start using the
above many times, does someone have a better idea? And, no, going back
to COBOL won't be better :-)

Steve Eisenberg Pennsylvania U.S.A.

Jun 15 '06 #3
Cor Ligthert [MVP] wrote:
In addition to Carsten, Jay has somewhere in this newsgroup once showed all
the possibilities to start-up a VBNet application.


My Googling skills failed in trying to find that. The OP question is
one I do find asked a few times before, but it never has quite been
given the slick answer I thought might be possible.

I thank Carsten for his method, but it loses the ApplicationEvents. If
you are used to going without them, that's no problem, but as soon as I
saw that feature, I wanted it.

I now have an alternate method that is maybe just slightly less clunky
than the one in the OP, but it still requires having a non-functioning
form. In the Startup ApplicationEvent, I launch a procedure which is
the starting point for the true application, like this:

Private Sub MyApplication_Startup(ByVal sender As Object, _
ByVal e As _
Microsoft.VisualBasic.ApplicationServices.StartupE ventArgs) _
Handles Me.Startup
StartupProc()
End Sub

StartupProc in this example is a Friend Sub in a standard module. By
the way, what I call StartUpProc cannot be called Main. Just about
anything else is fine.

Then, in the Load routine of the otherwise unused form, I have this:

Me.Close()

In this scheme, all the processing is acutally occurring during the
Startup event, and the startup form never finishes loading. Thinking
there could be a problem getting to other applications events when you
were still technically in the Startup ApplicationEvent, I tested
StartupNextInstance and UnhandledException successfully. I assume that
NetworkAvailabilityChanged will work as well. So there is no
functional or maintainability problem, just that it doesn't seem right
for someone looking at your code to see a form requiring an
explanation.

Thanks for all ideas, or for pointing out something obvious that I'm
missing.

Steve Eisenberg Pennsylvania, U.S.A.

Jun 16 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Brian Fulford | last post: by
7 posts views Thread by Ż5 | last post: by
10 posts views Thread by kimiraikkonen | last post: by
3 posts views Thread by Dean Slindee | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.