Steven
Steven

Reputation: 13769

Prevent Console Return

Can a VB.NET Windows Forms Application be configured so that when run from the command-line, the command-line waits until the application exits before showing the next prompt?

Upvotes: 4

Views: 158

Answers (4)

lxalln
lxalln

Reputation: 930

The code after Application.Run(new Form1()); is only run after the application has been exited. No configuration needed.

static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        string s = "test string";
        s.Trim();
    }

Upvotes: 1

Frank Bollack
Frank Bollack

Reputation: 25166

You can change the command to start your application from the command line to:

start /wait YourApplication.exe

In general the command line behavior depends on the subsystem your application is using (Console/Windows). As an Application with the subsystem Windows doesn't have standard input/output streams, there is no need for the console to wait for them.

But you can change your application to be a console app and use your existing forms as usual. This link shows an example.

Upvotes: 4

Mike L
Mike L

Reputation: 4913

Unless the command-line is your own console app, then no.

I suppose you could create a console app that shelled out to the windows forms app... a bootstrapper of sorts. If the console app were to be launched by command-line, it might do the trick.

Upvotes: 0

Mark Hurd
Mark Hurd

Reputation: 10931

I think the answer is No, but a console application can show forms.

Upvotes: 0

Related Questions